Sunday, May 10, 2009

Redirecting your domain with c-panel

I have found a problem when trying to redirect the www to non-www using the c-panel redirect utility.

It is known that the search engines treat your site yourdomain.com and www.yourdomain.com as two completely separate sites. This is not how you want it to work. To remedy this situation you need to create a 301 redirect to point your www.yourdomain.com links to yourdomain.com.

Unfortunately, the c-panel redirect utility will not allow you to add the slash to the end of the domain i.e. http://yourdomain.com/

You will need to edit the .htaccess file directly. You can add the 301 redirect using the c-panel utility and then edit it adding in the slash or just add the following to the .htaccess file.

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

This should redirect all traffic with the www to the non-www domain.