Skip to content

Instantly share code, notes, and snippets.

View bartclaeys's full-sized avatar

Bart Claeys bartclaeys

View GitHub Profile
@ladislavsulc
ladislavsulc / .htaccess
Last active July 20, 2019 21:14
SSL redirect 301
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]