How-To switch between HTTP and HTTPS

New to mod_rewrite? This is a good place to start.

How-To switch between HTTP and HTTPS

Postby glagnese » Thu Sep 05, 2002 5:53 am

I'm confused as to why this will not work and why ModRewrite thinks it's getting port 80 when the browser says it's using 443.

#Enter a URL for /html/secure/foo.html
#RewriteCond: input='/pls/secure/foo.html' pattern='^.*/secure/.*' => matched
#RewriteCond: input='80' pattern='!^443$' => matched
#rewrite /pls/secure/foo.html -> https://...
#explicitly forcing redirect
#
# Therefore this works
RewriteCond %{REQUEST_URI} ^.*/secure/.*
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*/secure/.*) https://%{SERVER_NAME}/$1 [L,R]

# Now navigate to a non-secure page using a link from a secure page and I get...
#RewriteCond: input='/images/header/...' pattern='!^.*/secure/.*' => matched
#RewriteCond: input='80' pattern='^443$' => not-matched
# If I put a condition within a <Location /pls/secure> to indicate port it correctly shows the 443 port!
# The browser URL still shows https and the lock is still visible (from a Windows IE client)
RewriteCond %{REQUEST_URI} !^.*/secure/.*
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^.* http://%{SERVER_NAME}/$1 [L,R]

I have this in the <Location> but even with it disabled I get the same results:
<Location /pls/secure>
...
RewriteEngine on

RewriteCond %{HTTPS} !=on
RewriteRule .* - [F]
...
</Location>

Any help is GREATLY appreciated.
glagnese
 
Posts: 1
Joined: Thu Sep 05, 2002 5:33 am

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 10 guests

cron