I have a primary domain https://www.domain.com
or https://domain.com
and a wildcard DNS like https://domain.com/index.php?name=abcd
redire
You already have the rule for rewriting to https
, the only thing left is excluding login.php
RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain\.com)$
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/login\.php$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
If login.php
is requested with https
, rewrite it to http
RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain\.com)$
RewriteCond %{HTTPS} on
RewriteRule ^login.php$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
Finally, a minor hint: never test with 301
enabled, see this answer Tips for debugging .htaccess rewrite rules for details.