Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HSTS & URL rewrite

15 views
Skip to first unread message

Bevan Robinson

unread,
Sep 16, 2021, 11:19:00 PM9/16/21
to
I'm trying to enable HSTS and also force visitors onto https:// and include the www in any URL's. This is what I have in my .htaccess file. Is this correct?

RewriteEngine On

Header set Strict-Transport-Security "max-age=31536000" env=HTTPS

# If https send to https://www.
RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
0 new messages