The goal is to have every page (minus one folder) of a site redirect to https. I've discovered the following does not do that. The one folder contains a subdomain. Let's call it mahogany.com.
Edit: Modify rules
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.site1\.mobi [NC,OR]
RewriteCond %{HTTP_HOST} ^site1\.mobi [NC,OR]
RewriteCond %{HTTP_HOST} !^mahogany\.com [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If someone types site1.mobi
or www.site1.mobi
into their browser, apache with the above in the document root htaccess will not redirect.
What is wrong with the above? Is a line for mahogany.com needed to exclude it?
The default logical operator for
RewriteCond
is "and"; theHTTP_HOST
can't be both of those so the condition will never be satisfied.Try this:
Also, you mentioned a directory exception, but I don't see one in there. You can add one with an extra
RewriteCond
or by changing yourRewriteRule
condition: