Using .htaccess to move domains
To maintain traffic and search engine rankings after moving a website, it is really useful to use the address rewriting capabilities available on most modern web servers. The ReWrite Module is often available on both Apache and IIS web servers to facilitate this. This, coupled with a 301 Permanent Redirect instruction allows you to redirect all of the old pages from a domain to the equivalent area on a new domain by matching the pattern, rather than listing thousands of individual redirect instructions.
The example instruction below will redirect www.myoldsite.com/anyexistingpages.htm to www.mynewsite.ie/anyexistingpages.htm in just four lines of code.
RewriteEngine On
RewriteBase /
Rewritecond %{HTTP_HOST} www\.myoldsite\.com$
RewriteRule ^.*$ http://www.mynewsite.ie/{R:1} [R=301,L]
The code should be added to the .htaccess file which resides in the root of your website directory. Remember to always backup before attempting changes. Incorrect changes to a .htaccess file can render your website inaccessible.
- Rate this item
- Published in Blog