[solution] Adding "www." in front of your domain using htaccess rewrite rules ( modrewrite ) force


min read

My profile

Share this:

Even better, for all names:

[code:1:b9951d1bb3]RewriteEngine On
RewriteBase /
# non empty HTTP_HOST in the request
RewriteCond %{HTTP_HOST} !^$ [NC]
# does not start with ‘www’
RewriteCond %{HTTP_HOST} !^www. [NC]
# saves the value of HTTP_HOST in %1
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
# redirects using the saved URI (in RewriteRule) and saved hostname (in the last RewriteCond)
RewriteRule ^(.*)$ “http://www.%1/$1” [L,R=301]
# that’s it ![/code:1:b9951d1bb3]


Share this:

Leave a Reply

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