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


gethan - 6:22 am on Apr 3, 2003 (gmt 0)


First split up the directories for each host... make your problem simpler. eg. www.domain.com has a different root to domain.com.

Then have a look here: [webmasterworld.com...] - simple example... your rules should be along the lines of

(spot the q's :))

.htaccess in the olddir -> newdir directory

rewriteEngine on
rewriteBase /olddir/
rewriteCond %{HTTP_HOST} ^olddomain.com$ # says must be only olddomain.com not www.olddomain.com
rewriteRule ^(.*) httq://newdomain.com/newdir/$1 [L,R=301] # gets the directory move.

.htaccess in the main directory

rewriteEngine on
rewriteBase /
rewriteCond %{HTTP_HOST} ^olddomain.com$ # says must be only olddomain.com not www.olddomain.com
rewriteRule ^(.*) httq://newdomain.com/$1 [L,R=301] # gets the directory move.

Could spend some time rewriting this into a single .htaccess - my mod_rewrite is a little rusty atm though. Good luck - and I hope this sends you on the right track.

===
In general (for other visitors) there are simpler methods that you should consider if:
- you don't have any deep links.
- users don't have bookmarks to deep pages.

They include

[webmasterworld.com...]

mod_alias:
RedirectMatch 301 /english/(.*\.html)$ htt*://www.newsite.com/$1

permenant redirect:
RedirectPermanent / httq://www.newurl.com/


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