0

I would like to force HTTPS (SSL) on every page except /es-ES/calculador-cuatro-pilares-destino-bazi.html or /en-US/bazi-calculator.html. How can I do that? I am using Apache HTTP Server (ver 2.2.x).

This is my current .htaccess file:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/es-ES/calculador-cuatro-pilares-destino-bazi\.html
RewriteCond %{REQUEST_URI} !^/en-US/bazi-calculator\.html
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/es-ES/calculador-cuatro-pilares-destino-bazi\.html
RewriteCond %{REQUEST_URI} ^/en-US/bazi-calculator\.html
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

1 Answer 1

1

You don't actually say what the problem is with the code you posted. However, you need an OR flag on the second RewriteCond directive of the second rule block (ie. HTTPS to HTTP redirect) as you want either of those URLs redirected back to HTTP - the request can't match both at the same time!

For example:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/es-ES/calculador-cuatro-pilares-destino-bazi\.html [OR]
RewriteCond %{REQUEST_URI} ^/en-US/bazi-calculator\.html
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You are not using the RewriteRule pattern, so there is no need to capture anything.

You will also need to make sure your browser cache is clear before testing.

(However, why are you redirecting HTTPS to HTTP? This is unusual and should be avoided in today's HTTPS-everwhere philosophy.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.