Logo
Print this page

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.

Privacy Policy   |   © Sharkey Consulting: Online Shopping Experts. All rights reserved.

Sharkey Ecommerce Consulting Ltd. and this site is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.