.htaccess – A Weblog of Priyank Maniar https://priyank.rocks Articles on web development & mobile app development Fri, 31 Aug 2018 09:13:31 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 .htaccess generic rules for non www to www redirect with https https://priyank.rocks/htaccess-generic-rules-for-non-www-to-www-redirect-with-https/ Fri, 31 Aug 2018 09:13:31 +0000 http://priyank.rocks/?p=159 These are generic rules. Should work out of the box for any site.

1
2
3
4
5
6
7
8
9
10
11
12
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
]]>