I'm looking to 301/302 all requests to a domain1 to domain2, except when someone requests the homepage of domain1 (eg www.domain1.com, www.domain1.com/ or www.domain1.com/index.html), in which case a file on domain1 will be served. Any solutions? Here's my (non working) attempt.. RewriteEngine on RewriteRule ^$ index.php [L,NC] RewriteRule ^/$ index.php [L,NC] RewriteRule ^/index.html$ index.php [L,NC] RewriteRule ^/(.+) http://www.domain2.com/$1 [L,R=301,NC]
This is pretty unusual, but depending upon the amount of URL's you have, it might be best to set up all of the redirects as separate entities, minus the home page. e.g. redirect 301 redirect 301 redirect 301 redirect 301 redirect 301 I presume that the links will not be growing so you could list all of your filenames (drop the index file - index.html) from your home directory and allow indexes- this should only take you a second to do) copy them into excel and write a concatenate script that would prefix the filenames with "redirect 301". In fact, i've done one for you - so you understand. This will save you a bucketload of time!
Thanks so much for your time Stuey! That's a neat solution, but unfortunatley the domain in question has over 20,000 pages of which most are dynamic and generated from the database Although I could use my Google sitemap file to provide the static urls in a handy list if theres no alternative
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^(.*)$ http://www.domain.com/$1/ [R=301,L] RewriteRule ^index.php$ index.php [L] RewriteRule ^$ index.php [L]