Let's say we have two domains www.mydomain.com and www.mydomain.co.uk
Our main site is on www.mydomain.com
We have a separate hosting account, on the same server, for www.mydomain.co.uk - all this does is have an .htaccess file which redirects to mydomain.com
[CODE] RewriteEngine on RewriteCond %{HTTP_HOST} ^([^.:]+\.)*mydomain\.co.uk\.?(:[0-9]*)?$ [NC] RewriteRule ^(.*)$ http://www.mydomain.com/?referrer=mydomain.co.uk [R=301,L] [/CODE]
We also have set up a blog, on www.mydomain.com/blog/
PROBLEM: We also want the subdomain: http://blog.mydomain.co.uk to forward to http://www.mydomain.com/blog/ as the "blog.mydomain.co.uk" is more popular (as it开发者_如何学Python exists currently on a Google blog).
SOLUTION: We can either direct the "blog.mydomain.co.uk" subdomain to "mydomain.co.uk", and set up .htaccess on that .co.uk hosting account to redirect (301) to mydomain.com/blog/
OR
we can direct the "blog.mydomain.co.uk" subdomain to "mydomain.com" and set up the .htaccess on that sire to redirect as above.
Just wondering what you would choose? Is there any difference between the above, in terms of search engine optimisation? What's the 'better' way of doing it?
You shouldn't be paying for two accounts; you can have multiple domains pointing to the same server space, and handle the rewrites there. The best thing for SEO is to choose one as the primary domain and stick to it; that way you don't spread your web hits across multiple domains.
Neither of your solutions seem like completely the right answer. You're not really using mod_rewrite for it's power; you're just doing redirects (not internal rewrites), since you always do a 301, and you always provide a full URL (which implies a redirect, not a rewrite). There's no need to do the two-stage redirect you describe. Just redirect directly from the blog.mydomain.co.uk virtual host to mydomain.com/blog/, in one step.
精彩评论