I have put this code into my htaccess but it won't redirect blog.mydomain.com to mydomain.com Anyone know how I can get it working? RewriteEngine on RewriteCond %{HTTP_HOST} !^mydomain.com RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301] Code (markup):
This code looks okay. Is the blog subdomain correctly defined ? What do you get when you try to go to blog.mydomain.com ? Jean-Luc
It seems that your subdomain is not correctly defined. Check the control panel of your host. If you are lucky enough to use cPanel, there will be a "Subdomain" icon where you can easily define new subdomains. I do not understand why you want to add this subdomain, just to redirect it to the main domain though. Jean-Luc
First thanks for your advice I don't want to add the subdomain, it is already there, well kinda, you see this domain has been parked for some time and I have finally decided to develop it but I see that google still has the "blog" subdomain cached, thus I want to redirect it to the main domain to help with seo and any traffic that may be going (or should I say trying to go) to the old subdomain. You get me?
Yep, very clear! Creation of new subdomains is very much host dependent. Some hosts limit the number of subdomains you can create. Ask your hosting company, if my comments don't solve the issue. Jean-Luc
I guess I can't redirect something that does not exist now that I think of it I feel a bit dumb to think i could redirect the subdomain without even creating it lol. Thanks Jean-Luc!
Looks like the code was based on being located at domain.com, not blog.domain.com RewriteEngine on RewriteCond %{HTTP_HOST} !^blog.mydomain.com RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]