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 / 
1

6 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:

3

Are you trying to get visitors to to go to If so, you can do this with a mod_rewrite rule in .htaccess:

RewriteEngine on

RewriteRule ^(.*)$ [R=permanent,L]

1

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] 
3
RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC] RewriteRule ^(.*)$ "" [R=301,L] 

Add this for pages not currently on your site...

ErrorDocument 404

Along with your Redirect 301 / that should cover all the bases...

Good luck!

0

HTAccess 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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy