The Joomla! Forum ™






Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Oct 11, 2010 4:58 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jul 11, 2008 4:54 pm
Posts: 22
I've been trying to figure out the best way to do this, and would be interested to hear anyone's suggestions.

Situation: main site is http://www.example.com. Just moved our blog from a 3rd party blog provider, where it was located at blog.example.com, to our main site -- currently http://www.example.com/blog. Would really like to keep blog.example.com (or even blog.example.com/blog if necessary, as I suspect it might be) for branding reasons.

Currently all subdomains point to the main site. I use mod_rewrite to point the blog subdomain to http://www.example.com/blog, and 301 redirects to point the individual article pages to their new URLs (only about 50 or so articles). Code for that first part (super basic):
Code:
RewriteCond %{HTTP_HOST} ^blog.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/blog/$1 [L]


I can point blog.example.com to blog.example.com/blog using a similar method, the main difference being that I have to exclude the situation where index.php is being requested, because otherwise it will be an infinite loop. Here's the code for that, FYI:
Code:
RewriteCond %{HTTP_HOST} ^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?Itemid=27 [NC,L]


But then if someone clicks back from the blog to another section of the site, the blog subdomain stays in the URL, which is not cool. :( So then I scrapped the previous attempts and tried to add the subdomain to the URL IF you're on one of the pages or components USED by the blog (slightly different logic):
Code:
#RewriteCond %{HTTP_HOST} !^blog\.example\.com [NC]
#RewriteCond %{REQUEST_URI} ^/(blog|keyword|component\/blog_calendar) [NC]
#RewriteRule ^(.*)$ http://blog.example.com/$1 [NC,L]


That works, but then there's the same problem of needing to REMOVE the subdomain when someone LEAVES one of the blog sections. I thought I could just copy/paste the above block and switch the negating exclamation point from the first Cond to the second one, and change the Rule to go to www instead of blog. Unfortunately, that just dumps me at index.php whenever I try to go to a blog page. I dunno what's going on. Here's both blocks together, maybe someone can tell me what I'm doing wrong:

Code:
RewriteCond %{HTTP_HOST} !^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} ^/(blog|keyword|component\/blog_calendar) [NC]
RewriteRule ^(.*)$ http://blog.example.com/$1 [NC,L]

RewriteCond %{HTTP_HOST} ^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} !/(blog|keyword|component\/blog_calendar) [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [NC,L]


The culprit is definitely the second Cond on the second block, it seems to be ignoring those, so dumping back to index whenever the subdomain is blog.

I tried this, since sometimes the request URI is in Joomla query string format (for reasons I can't figure out):
Code:
RewriteCond %{HTTP_HOST} ^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} !Itemid=(27|158|159|179|184) [NC]
RewriteCond %{REQUEST_URI} !option=(com_blog_calendar|com_sectionex|com_tag) [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [NC,L]


Results in an infinite loop if both blocks are on, and results in always removing the blog subdomain if the first block is disabled. So again, the second and 3rd Conds are not working.

Any ideas as to what I'm doing wrong? I'm also open to completely other suggestions. Mod_rewrite is just how I'm accustomed to doing these sorts of things.

Thanks a bunch for reading, and for any help in advance. :)


Top
 Profile  
 
PostPosted: Mon Oct 11, 2010 5:29 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jul 11, 2008 4:54 pm
Posts: 22
Okay, it's working. Here are the 3 relevant blocks:

Code:
RewriteCond %{HTTP_HOST} ^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/index\.php [NC]
RewriteCond %{REQUEST_URI} ^/(blog|keyword|component\/blog_calendar) [NC,OR]
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?Itemid=27 [NC]

RewriteCond %{HTTP_HOST} !^blog\.example\.com [NC]
RewriteCond %{REQUEST_URI} ^/(blog|keyword|component\/blog_calendar) [NC]
RewriteRule ^(.*)$ http://blog.example.com/$1 [NC,L]

RewriteCond %{HTTP_HOST} ^blog\.example\.com [NC]
RewriteCond %{QUERY_STRING} !Itemid=(27|158|159|179|184) [NC]
RewriteCond %{QUERY_STRING} !option=(com_blog_calendar|com_sectionex|com_tag) [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [NC,L]


I feel like that's longer than it needs to be, so if you see room for pruning, PLEASE do. The only downsides right now are possible performance issues (redirects), possible SEO issues (if you know more about how this affects SEO, please do share, since that's the reason we are doing this in the first place), and the fact that all local (relative) links on a blog page will appear to go to blog.example.com/whatever, even if they aren't in the blog section. Once the link is clicked, the redirect swaps the blog for a www, but still. Not great. Ideas?


Top
 Profile  
 
PostPosted: Fri Nov 05, 2010 1:46 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jul 11, 2008 4:54 pm
Posts: 22
Bump.

What have other people done for this? This way is so roundabout, it seems like there must be an extension or something for this. I've run into other problems this way, such as, login information is not carried across subdomains, and clicking a Home link while in the blog section only takes you to the home of the blog, not the main home.

Ideas? Anyone? :(


Top
 Profile  
 
PostPosted: Fri Nov 19, 2010 4:50 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Apr 12, 2010 3:25 am
Posts: 119
I have no ideas, but I too, am looking for instructions on how to create subdomain while using the regular Joomla installation

_________________
http://websonalized.com Small Business Web Design


Top
 Profile  
 
PostPosted: Sat Nov 27, 2010 12:25 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Jan 29, 2008 9:18 pm
Posts: 4
I'm looking for some information on doing this as well. I'm looking to display a couple of components as subdomains, essentially just like Joomla does right here at joomla.org... notice the domain here in the forum, forum.joomla.org... or in the extension directory at extensins.joomla.org. In fact Joomla.org has a large number of subdomains in use.

So, how is it done here on Joomla.org?

Here are some of the components I'd like to do this with...

VirtueMart as shop.domain.com
Sobi2 as merchants.domain.com
EZ Realty as homes.domain.com
Kunena as forum.domain.com

I also have a couple of sections that I'd lie to do this to as well... it's a magazine format and there are a couple of 'supplemental' sections that I want to use a different template and different layout for... highschoolsports.domain.com.

Anybody know how this domain trick is accomplished, aside from addition installs in subdomains?

I am aware of the JMS Multisite components... is that it... is that the trick? I was under the impression that there was another way.

Thanks.


Top
 Profile  
 
PostPosted: Sat Nov 27, 2010 12:35 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Jan 29, 2008 9:18 pm
Posts: 4
By the way... I'm going to be trying Virtual Domains Beta. It looks like it may work for what I trying to do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group