Tuesday, September 10, 2013

Apache to force certain URL for HTTP and all others go via https

Apache to force certain URL for HTTP and all others go via https

First i have to say I found many answers for revise situation but not for
this.
Apache to force certain URL for HTTP and all others go via https. Would
like to get expert knowledge on following. Thanks for all of your time and
appreciate that.
We have apache fronting tomcat in our production environment and we would
like to enable https for all the incoming except for few pages and would
like help on writing solid apache rewrite rule to do this . That is
All incoming connection go via https except for some pages (/abc, /def,
/ghi) to force http.
Any help. Icame up with this with help of google ļ but its not working
for http. All traffic goies to https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(/abc|/def|/ghi)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/(/abc|/def|/ghi)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

No comments:

Post a Comment