Last active
November 9, 2017 14:16
-
-
Save jonnitto/0be3c3a578f839691807a4b9b33b2f90 to your computer and use it in GitHub Desktop.
Top-level and subdomain based condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force https | |
RewriteCond %{HTTP_HOST} !\.test$ | |
RewriteCond %{HTTP_HOST} !\.prod$ | |
RewriteCond %{HTTP_HOST} !^stage | |
RewriteCond %{ENV:HTTPS} !=on | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Force www | |
RewriteCond %{HTTP_HOST} !\.test$ | |
RewriteCond %{HTTP_HOST} !\.prod$ | |
RewriteCond %{HTTP_HOST} !^stage | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment