Maybe it’s just me, but I get kind of
annoyed when websites are accessible by both their non-www and www URL.
If you attempt to go to my site by using http://szcpost.com/,
you’ll see that you’re automatically sent to
http://www.szcpost.com/ instead.
Why should you do this?
If you require people to login to your site, you probably give them
a cookie so they don’t have to login each time. But that cookie is only
good for one or the other URL, not both. So if somebody logs in using
http://szcpost.com/ and comes back later using
http://www.szcpost.com/, they’ll be forced to login again, even though
a cookie already exists for them using the other version.
Also, forcing one URL variety over the other ensures that you won’t
be double indexed or receive split page ranks in the search engines.
While Google does a pretty good job on their end of preventing this,
it’s possible that you could have two distinct page rank values for
each version of the web page, even though they are 100% identical in
content, but only differing in the presence of “www” in the URL.
How do you do it?
It’s simple really. Just add the following code to your .htaccess
file in the highest folder of your web directory and yor visitors will
be forced to use the www version.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^szcpost.com [NC]
RewriteRule ^(.*)$ http://www.szcpost.com/$1 [L,R=301]