Skip to content

Instantly share code, notes, and snippets.

@sumit-sampang-rai
Last active August 17, 2018 08:43
Show Gist options
  • Save sumit-sampang-rai/d4d399db7558691600fc2b6db4019c83 to your computer and use it in GitHub Desktop.
Save sumit-sampang-rai/d4d399db7558691600fc2b6db4019c83 to your computer and use it in GitHub Desktop.
Apache SSL redirection
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment