How to Force WWW (or no WWW) using HTACCESS in Domain Name
Posted by Nick Aviles on December 10, 2009
Posted by Nick Aviles on December 10, 2009
It’s quite important to modify your .htaccess file in the root of your domain in order to prevent duplicate content in search engines. Google, and other search engines, may penalize you for having duplicate content, and even drop you in rankings. To avoid this from happening, decide whether you want to have www. before your domain name or not.
If you want your site to look like http://www.nickaviles.com, paste this inside your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.nickaviles\.com [NC]
RewriteRule ^(.*)$ http://www.nickaviles.com/$1 [R=301,L]
If you want your site to look like http://nickaviles.com, paste this code inside your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.nickaviles\.com$ [NC]
RewriteRule ^(.*)$ http://nickaviles.com/$1 [R=301,L]
What is the difference between using www or not using www? Absolutely none. It doesn’t matter which one you pick, as long as you stick to one, all should go well.
Building Backlinks
Please note that if you’re building backlinks for your domain and some of your backlinks have no www but your site is forced www (or vice versa) the search engines will automatically consider them as www because you are using permanent redirect.
This would not work, however, if you would not use permanent redirect using .htaccess or PHP. So keep in mind to set up a permanent redirect for either one. Never have both www and no www working at the same time. Unless you want to drop out of rankings that is.
Tell me what you think about the post, I don't bite!