Question:
Following statements are there in my Apache2 virtual hosts section
Redirect /host/directory/folder/login.php https://servername/host/directory/folder/login.php
Redirect /host/directory/folder/register.php https://servername/host/directory/folder/register.php
How to return to http (not https) when the above 2 pages are not involved?
Answer:
In HTTP VH:
RewriteRule /.../login.php https://.../login.php [R]
RewriteRule /.../register.php https://.../register.php [R]
In HTTPS VH:
RewriteRule /.../login.php - [S=2]
RewriteRule /.../register.php - [S=1]
RewriteRule ^/(.*) http://servername/$1 [R]
In the HTTPS VH, if you get login.php or register.php you don't rewrite it (the "-"), then you skip the next 2 or 1 RewriteRules ( [S=2], [S=1]) - that is, you skip over the general purpose rewrite back to HTTP. So login.php or register.php get served from HTTPS and everything else goes back to HTTP.
Thursday, June 21, 2007
Subscribe to:
Posts (Atom)