# Go to http if you are on firmware
RewriteCond %{SERVER_PORT} !80
RewriteCond %{REQUEST_URI} ^/firmware$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
This code should redirect /firmwire
to http
instead of https
.
Both your code blocks redirect to HTTPS. In fact, you would expect the above to trigger a redirect loop since it is potentially redirecting to itself. That is unless /firmware
is a physical filesystem directory - or it's not actually being processed at all?
But example.com/firmware
redirect to example.com/index.php
This suggests you have a conflict with existing directives - perhaps your redirects are in the wrong place? The order of mod_rewrite directives is important.
These directives need to go near the top of your .htaccess
before the Drupal front-controller.
These directives can also be tidied a bit; no need for the additional condition that checks the URL-path. This check should be performed by the RewriteRule
pattern. For example:
# Go to https if not on firmware
RewriteCond %{SERVER_PORT} 80
RewriteRule !^firmware$ https://www.example.com%{REQUEST_URI} [NC,R,L]
# Go to http if you are on firmware
RewriteCond %{SERVER_PORT} !80
RewriteRule ^(firmware)$ http://www.example.com/$1 [NC,R,L]
The NC
flag is only required if /firmware
really can be mixed case.
If /firmware
is a physical filesystem directory then this may need modifying (as mod_dir will, by default, append a trailing slash).