Reputation: 501
I am trying to force https and redirect non-www to www:
The problem is I have many sudomains and I don't have wildcard ssl (for now) so I want :
Is that possible ?
All the ansewers i found and tested only force https or redirect all non-www to www my problem is i don't want subdomains get https except for www and redirect non-www to www
Upvotes: 3
Views: 780
Reputation: 41219
To force https://www only for the www.example.com , you can use :
RewriteEngine on
#redirect http non-www to https://www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
#redirect https non-www to www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
Upvotes: 5