Knowledgebase: Linux Hosting (CPanel)
How to do URL redirection using .htaccess
Posted by - NA - on 26 March 2010 06:00 PM
Issue

Unable to redirect web site traffic from your old pages to the new pages without losing your rankings


Symptoms

None


Cause

Lack of knowledge on performing redirection using .htaccess


Workaround


Redirect Old domain to New domain (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain. The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.yournewdomain.com/$1 [R=301,L]

Please REPLACE www.yournewdomain.com in the above code with your actual domain name.

Note: This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.


Redirect to www (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all requests coming in to yourdomain.com will get redirected to www.yourdomain.com The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^yourdomain.com [nc]
rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]

Please REPLACE yourdomain.com and www.yourdomain.com with your actual domain name.

Note: This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.


Additional Information

If the problem still persist, kindly issue a ticket to Support Team


Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).