Reputation: 273
How to force HTTPs just if the domain contains -facebook
?
I mean for example force HTTPs if domain is demo-facebook.domainname.com
Rewrite rule is this
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [NC,L,R]
but I have problem with the RewriteCond
All rule conditions that I found are related to words inside the URL not in the domain.
Upvotes: 1
Views: 43
Reputation: 785561
You will need a RewriteCond
using HTTP_HOST
variable to compare a substring in domain name like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} -facebook\.domainname\.com$ [NC]
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
Upvotes: 1