Force www or non-www website URL

Post Reply
User avatar
isscbta
Posts: 39
Joined: Mon Jul 19, 2021 1:41 am

To force www in your website URL (www.domain.com) at the beginning of your .htaccess file add:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
To force non-www in your website URL (domain.com) at the beginning of your .htaccess file add:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Just change domain.com to your own website domain

Tags:
Post Reply