How to set up www and https

To change a site’s URL to www with or https, use a .htaccess file. The specific configuration is shown below.

From no www to “https://www.example.com

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example.com$ 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

From http to “https://example.com

RewriteEngine on 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

After applying these settings, if a visitor accesses a URL without www or http, he/she will be automatically redirected to a URL with www or https.

Leave a Comment

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

Scroll to Top