How to .htaccess redirect all pages to new domain : You have an old website that is accessible under and you have a new website that is accessible under . Copying the content of the old website to the new website is the first step – but what comes after that?

How to .htaccess redirect all pages to new domain

You should do a 301 moved permanently redirect from the old domain to the new domain – which is easy and has some advantages:

  • Users will automatically be redirected to the new domain – you don’t have to inform them.
  • Also search engines will be redirected to the new domain – and all related information will be moved to the new domain (but this might take some time).
  • Google’s PageRankTM will be transfered to the new domain, also other internal information that is being used to set the position of pages in the search engine result pages (serp’s) – like TrustRank.


How can I migrate domain content with .htaccess?

Migrate domains

But if I navigate to I get redirected to I am expecting a redirect only to without the page suffix.

Here, this one redirects everything after the domain name on the url to the exact same copy on the new domain url:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ [R=301,L]

This is a good way of transfering link juice from a domain name that you just bought to another existing domain you already own. The newly purchased site could have many links already built up over time and by properly 301 redirecting all page URLs to your existing site you are better able to take advantage of your purchase. Note that the “.*” on the RewriteCond above which will catch any subdomain such as “www” and redirect that as well to the new domain.

RewriteEngine on 
RewriteRule ^(.*)$$1 [R=301,L] redirects to

Just to clarify, after removing the hosting redirect which was in the way, my original solution also works:

RewriteEngine On
RewriteRule ^(.*)$ [R=301]

This is good if you have more than one domain name pointing to the same web root directory and want to make sure that all requests to all domains get routed (301 redirected) to a single domain. You may run into this situation if you have a new domain that you want to use in place of your old one but want to transfer all the link juice from the old domain into the new one. Note, this solution doesn’t 301 redirect old page URL’s, it just redirects at the domain level.


  • How to transfer domains with htaccess
  • htaccess redirect