Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active November 30, 2017 13:31
Show Gist options
  • Save peacefulseeker/116b1b7e57db7faab6e92c5b2b98f6a8 to your computer and use it in GitHub Desktop.
Save peacefulseeker/116b1b7e57db7faab6e92c5b2b98f6a8 to your computer and use it in GitHub Desktop.
Htaccess HTTPS and WWW. force in URL
# Taken from here : https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment