Portal Home > Knowledgebase > HTML > Redirecting non-www to www with .htaccess

Redirecting non-www to www with .htaccess

To redirect all non-www requests to your site, just add the following code to your .htaccess file.

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

It will redirect any requests to http://my-domain.com to http://www.my-domain.com. There well be several benefits:

  • Avoid duplicate content in Google Search
  • also avoid the possibility of split page rank and/or split link popularity (inbound links).
  • Nicer, and more consistent.


 

Powered by WHMCompleteSolution