Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Changing domain names with mod_rewrite


franklin_dematto - 5:43 am on Apr 3, 2003 (gmt 0)


The official domain name of a site has changed from aaa.com to bbb.com. I'd like to use apache's mod_rewrite to issue a permanent redirect from any request with host aaa.com or www.aaa.com to bbb.com, with the same uri. Like this:

[aaa.com...] -> [bbb.com...]

for any dir/file etc.

This is complicated by a few things:
1) I only want to redirect requests that set a host to aaa.com or www.aaa.com. But if they issue no host, or different versions of bbb.com (like www.bbb.com or subdomain.bbb.com etc), I don't want to redirect it

2)Some URI's have changed, and I want to fix these in one redirect, and not have to do two:
ie [aaa.com...] -> [bbb.com...] in one permanent redirect

I can't seem to get the rewrite rules right! Can anyone help me?

Also, for reasons currently beyond my control, the rules must be done in the .htaccess, not the main httpd.conf


Thread source:: http://www.webmasterworld.com/apache/152.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com