apache - Can't get htaccess rule to work: force SSL on all pages, force non-SSL on two specific pages -


i no htaccess expert, after googling 2 hours gave up. maybe can me?

i have entire site on ssl. however, have 2 pages reference non-secure dynamic content elsewhere. need these on http instead of https.

the first part of rules work. site forced ssl except 2 pages. however, last part doesn't: force 2 pages non-ssl. stupid see go wrong?

#add www. if missing  works rewriteengine on rewritecond %{http_host} ^[^.]+\.[^.]+$ rewriterule ^(.*)$ https://www.%{http_host}/$1 [l,r=301]  #force ssl/https works rewritecond %{https} !=on rewritecond %{request_uri} !^/webshop2/localize\.php rewritecond %{request_uri} !^/webshop2/layoutstripper\.php rewriterule ^ https://%{http_host}%{request_uri} [l,r=301]  #force http not work rewritecond %{https} on rewritecond %{request_uri} ^/webshop2/localize\.php [nc] rewritecond %{request_uri} ^/webshop2/layoutstripper\.php [nc] rewriterule ^(.*)$ http://%{http_host}%{request_uri} [l,r=301] 

you need [or] flag in second ssl rule. 2 conditions have say:

  • the request must https
  • the uri must start with: /webshop2/localize.php
  • the uri must start with: /webshop2/layoutstripper.php

as can see, last 2 conditions fail, request can't both @ same time. if add [or] flag in there, makes true if uri 1 or other:

rewritecond %{https} on rewritecond %{request_uri} ^/webshop2/localize\.php [nc,or] rewritecond %{request_uri} ^/webshop2/layoutstripper\.php [nc] rewriterule ^(.*)$ http://%{http_host}%{request_uri} [l,r=301] 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -