Your Ad Here

Friday, January 24, 2014

How to redirect old domain to new domain or some location to new location

Implementing the www redirect

First, make sure that mod_rewrite is enabled.  Just make sure that this line appears somewhere in your .htaccess file above the rule that we are about to add:

RewriteEngine On

To redirect from non-www to the www version of your site,
 use the following rule:

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]

To redirect from www to the non-www version of your site, use the following rule:

RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule (.*)$ http://example.com/$1 [R=301,L]

Make sure that you replace ‘example.com’ with your actual domain!

To redirect from old domain to the new-domain of your site, use the following rule:


RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]


If you want to redirect from some location to subdomain you can use:

Redirect 301 /Old-Location/ http://subdomain.yourdomain.com