Question : How to redirect from SSL to non-SSL directories in Apache/IHS httpd.conf file

I am having trouble redirecting from SSL to non-SSL.  I can redirect from a non-SSL to SSL directory called /secure as follows:

RewriteCond  %{REQUEST_URI} ^/secure
RewriteCond %{HTTPS} !=on
RewriteRule .*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

But when I go to another directory on the site outside of this one, I can't get it to be non-SSL.  Here's my rewrite:

RewriteCond  %{REQUEST_URI} !^/secure
RewriteCond %{HTTPS} =on
RewriteRule .*$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Could someone tell me what I'm doing wrong?  Thanks for the assistance!

Answer : How to redirect from SSL to non-SSL directories in Apache/IHS httpd.conf file

Hi
Sorry for the delay in getting back to you, can you please confirm that your re-write rules are in the SSL Virtualhost, the one listening on port 443 e.g.


...
RewriteEngine on
RewriteLog "/tmp/tmp_rewrite.log"
RewriteLogLevel 9
RewriteCond  %{REQUEST_URI} !^/secure
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .*$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R]


As the rules work for me e.g.

192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (4) RewriteCond: input='/susehelp/' pattern='!^/secure' => matched
192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (4) RewriteCond: input='443' pattern='^443$' => matched
192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (2) rewrite '/susehelp/' -> 'http://192.168.0.10/susehelp/'
192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (2) explicitly forcing redirect with http://192.168.0.10/susehelp/
192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (1) escaping http://192.168.0.10/susehelp/ for redirect
192.168.0.9 - - [01/Aug/2009:20:48:38 +0100] [192.168.0.10/sid#5555557ef150][rid#5555563aac68/initial] (1) redirect to http://192.168.0.10/susehelp/ [REDIRECT/302]
Random Solutions  
 
programming4us programming4us