Forum Moderators: phranque
This is my first post. I found this forum via google. I have been fussing with this off and on for a couple weeks. I can get it to work for one, but not both.
I have a site - example.com.
both example.com and www.example.com take you to the same page. my company (example) was acquired, and i need the browser address bar to now show the new company name - new.com
i have successfully redirected other parts of the site - support.example.com to new.com/support, for example, using this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^support.example.com
rewriterule (.*) http://new.com/support/$1 [R=301,L]
I have tried using a rewriteCond with the www, with no luck.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [nc]
RewriteRule (.*) new.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com OR
RewriteCond %{HTTP_HOST} ^www.example.com [nc]
rewriterule (.*) http://new.com/$1 [R=301,L]
To complicate things - example.com was hosted internally, and IT set up something on the IIS server which handles the www to non-www mapping for example.com and www.example.com to make them go to the same page.
The new site is also hosted on a windows server, which is running ISAPI_Rewrite 3.
I feel like this should be possible - but I have not found the right combination yet.
So my question is - is this possible to rewrite new.com when someone enters www.example.com or example.com?
Thanks very much - all help appreciated.
[edited by: jdMorgan at 1:09 am (utc) on June 16, 2009]
[edit reason] de-linked [/edit]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://new.com/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule (.*) http://new.com/$1 [R=301,L]
Jim
[edited by: jdMorgan at 1:08 am (utc) on June 16, 2009]