httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clay Porter <>
Subject [users@httpd] Forcing certain pages from HTTP to HTTPS and vice versa
Date Tue, 27 Dec 2011 20:55:12 GMT
I am trying to set up rewrite rules so that when users access certain
pages via HTTP they are redirected to HTTPS. Conversely, if they
access pages that do not require security I want the user to be
redirected from HTTPS to HTTP.

I have looked at numerous examples and read the rewrite rule
documentation to no avail.  No matter what I've tried once a user is
on HTTPS they are never redirected back to HTTP.

FWIW, the HTTP to HTTPS portion appears to work and I can see the
activity in the rewrite log.

I'm running the binary distribution of Apache httpd Server version:
Apache/2.2.21 (Win32) with mod_ssl.  I've included the relevant
section of my httpd.conf below.  The httpd.conf file is the stock one
from the distribution with the necessary modules enabled so I didn't
include the whole thing here.

RewriteEngine On
RewriteLog logs/rewrite.log
RewriteLogLevel 3
#RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/secure/(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
#RewriteCond %{HTTPS} on
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !secure(.*)$
RewriteRule !^/secure/(.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R]

I apologize for the n00b question but I've spent a lot of time trying
to figure this out for myself.  I'm hoping someone will be able to
help me with this.



The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message