With WWW or Without WWW? How to Force Each One

This is one of eternal questions. The main important thing is that you have to decide which one of these two option you want to use. If you do not favor one of them, your SE rankings and signals can get messed-up and you will lose a lot on search engine visits.

Let’s explain commands that you have to insert into your .htaccess file to force each of these options.

Force option WITH www:

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

Mode2:
# Replace ‘example.com’ with your domain name
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Force option WITHOUT www:

# Replace ‘example.com’ with your domain name
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *