I would like to redirect all none-https requests to https excepts requests to sub-domains. For example
http://example.com/ => https://example.com/
http://example.com/page => https://example.com/page
But
http://m.example.com/ REMAINS http://m.example.com/
This is what I have in my .htaccess, which redirects all requests (including sub-domians):
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
I know that I have to add a condition before the RewriteRule but I am quite not sure about the syntax.
To Exclude any Subdomain from https rewrite add
RewriteCond %{HTTP_HOST} !=/(.*?)/.example.com
Add another RewriteCond
before your RewriteRule
:
RewriteCond %{HTTP_HOST} !=m.example.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With