jonnitto
11/9/2017 - 1:29 PM

Force https:// and www

Top-level and subdomain based condition

# 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]