I want to redirect all of my old domain request to my new domain using htaccess file. Below is what I am using but it does not work if the page is not on the new site. For example google index about.htm on the old site but on the new site it does not exist. I would like it to just go to the root in all cases. I know this is not ideal for seo but I don't want any 404s. Any suggestions?
Redirect 301 / 16 Answers
If your aim is to redirect all pages to a single maintenance page (as the title could suggest also this), then use:
RewriteEngine on RewriteCond %{REQUEST_URI} !/maintenance.php$ RewriteCond %{REMOTE_HOST} !^000\.000\.000\.000 RewriteRule $ /maintenance.php [R=302,L] Where 000 000 000 000 should be replaced by your ip adress.
Source:
3Are you trying to get visitors to to go to If so, you can do this with a mod_rewrite rule in .htaccess:
1
RewriteEngine on
RewriteRule ^(.*)$ [R=permanent,L]
This will direct everything from the old host to the root of the new host:
RewriteEngine on RewriteCond %{http_host} ^ [NC,OR] RewriteCond %{http_host} ^old.com [NC] RewriteRule ^(.*)$ [R=301,NC,L] 3RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC] RewriteRule ^(.*)$ "" [R=301,L] Add this for pages not currently on your site...
Along with your Redirect 301 / that should cover all the bases...
Good luck!
0HTAccess to send all pages of a website to one page. This worked for me:
ErrorDocument 404 /page-name.php or to a different domain...
RedirectMatch 301 ^/.*$ 0