Force Use of www in All URLs And Redirect Traffic With .htaccess


A website can be accessed with and If you visit any of these URLs, you will be sent to the same page but they will have different URLs.

The main problem is that Google and other search engines consider it as duplicate content and therefore penalize this domain in the search engine ranking.

The best way to get around this problem is to make sure that all your URLs on your site use a consistent URL format either or

Therefore with the help of htaccess, we can redirect all non-www URL traffic to You can just copy and paste this snippet below and replace with your domain.

# Force adding www in domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads