Please Login or Register

Knowledgebase

[How To] Redirect all to www. version of your site

Some users, particularly Search Engine conscious ones prefer only one version of their URL to be used because Search Engine Robots, like GoogleBot will view www.xdnet.co.uk and xdnet.co.uk as different websites, and because they display the same content it understands it as duplicate content, which (in Googles eyes) devalues your site and can affect your rankings.

Some prefer URLs like: www.MySite.com while others prefer using just plain MySite.com.

Below you can find two .htaccess snippets, one redirects all users to the www. version and the other redirects all to the plain version without the www.

Redirect all to www.

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

Redirect all to non-www. domain

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






Was this answer helpful?
Add to Favourites Add to Favourites   Print this Article Print this Article
Also Read

Powered by WHMCompleteSolution

Language:


Web Hosting
Client Login
Web Hosting

Email

Password

Remember Me


Web Hosting
Search
Web Hosting




Follow Us on Twitter