Force www or non-www website URL
Posted: Wed Aug 10, 2022 10:14 am
To force www in your website URL (www.domain.com) at the beginning of your .htaccess file add:
To force non-www in your website URL (domain.com) at the beginning of your .htaccess file add:
Just change domain.com to your own website domain
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]