Domain redirection

If you have changed your website domain, you will need to redirect people who are trying to access the old domain to the new domain.

This page is about domain redirection. For information on individual page redirection check out our webpage redirection tutorial.

Code to redirect from one domain to another:
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Place the above code into your .htaccess file. Replace newdomain.com with the domain that your visitors should be redirected to.

The above code assumes the same directory structure and filenames on your new domain as on your old domain. So for example, if your old domain was site1.com and your new domain is site2.com, if you try to access site1.com/web/tools.html the redirect will send you to the exact same location on site2.com...site2.com/web/tools.html.

NOTE: Other sites on the web probably have links back to your old domain. Find out which sites link back to you, get in contact with them and ask them to change their links to point to your new domain.

NOTE: If you're going to do a domain redirection, place the .htaccess file in the root directory of your web server for your old domain. This way all the pages on the old domain will be redirected to the right place on the new domain.

NOTE: This redirection scheme only works on web servers that run Linux AND have the mod-rewrite module enabled for Apache.

© Copyright 2013-2014 Landofcode.com
Terms of use | Privacy policy | Copyright information