I want simple to rewrite everthing from OLD.COM to NEW.COM including subdomains and stuff - whatever user types in should just be replaced with NEW.COM and the rest of it stays as is. I tried this but it's not working for subdomains.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^((www\.)?[^\.]+)\.old\.com [NC]
RewriteRule ^(.*)$ http://%1.new.com/$1 [R=301,L]

What did I miss? Thanks Bob

link|improve this question
feedback

1 Answer

Delete all the subdomains in the apache config and replace it with this:

Listen *:80
<VirtualHost *:80>
    DocumentRoot /var/www/ #Wherever your site is located now
    ServerName olddomain.com
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(.*)olddomain\.com$ [NC]
    RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]
</VirtualHost>

That should redirect all subdomains.

link|improve this answer
I tried it and this error comes up: "The server encountered an internal error or misconfiguration and was unable to complete your request." – Bob Apr 3 '11 at 18:51
Sorry, had a \ that wasn't supposed to be there. Does it work now? – Bart De Vos Apr 3 '11 at 18:53
still nothing happens if "WWW" is missing or by entering subdomains ( olddomain.com + subdomains.olddomain.com ) – Bob Apr 3 '11 at 19:24
Made some changes. Please try again. – Bart De Vos Apr 3 '11 at 20:17
only thing left is that subdomains aren't working are (like "anysubdomain.olddomain.com";) - is it a server-based problem or can it be solved via .htaccess? – Bob Apr 3 '11 at 20:58
show 7 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.