Search code examples
apache.htaccesshttp-redirectdns

htaccess redirect all pages to single page


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 / http://www.thenewdomain.com/

Solution

  • Are you trying to get visitors to old.com/about.htm to go to new.com/about.htm? If so, you can do this with a mod_rewrite rule in .htaccess:

    RewriteEngine on

    RewriteRule ^(.*)$ http://www.thenewdomain.com/$1 [R=permanent,L]