www vs no www

Note this only works on an Apache server with mod_rewrite turned on.
Google recommends using www or not www but not both. In other words, use www.mydomain.com or mydomain.com but not both. Using a 301 permanent redirect can alleviate the problem.
To redirect mydomain.com to www.mydomain.com do the following:

In an existing .htaccess file or a new .htaccess file add the following code:

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

Replace mydomain with the domain you want to redirect. r=301 means redirect the client and send a status code of 301.

Doug

Bookmark and Share
This entry was posted in Web Site. Bookmark the permalink.

One Response to www vs no www

  1. Pingback: Don’t Supplement the Supplemental Pages | Web Site Promotion

Leave a Reply