httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Axel-St├ęphane SMORGRAV <>
Subject RE: [users@httpd] Redirecting http traffic to an https virtual host
Date Fri, 03 Feb 2006 17:46:21 GMT
The rewrite condition is superfluous, and furthermore it is not because the connection is on
port 443 that it is necessarily SSL. Either you have "SSLEngine On" within that virtual host,
or you don't: that's what determines whether the VH uses SSL or not.

A better way of testing is to use the %{HTTPS} variable which either has either of the values
"on" or "off" depending on whether the request was made on an SSL connection or not.

        RewriteCond %{HTTPS} =off
        RewriteRule ^(.*)$ https://%{SERVERNAME}$1 [R]

If there is any chance that the SERVERNAME variable may contain a port number, you will need
to strip it off:

        RewriteCond %{HTTPS} =off
        RewriteCond %{SERVERNAME} ^([^:]*)
        RewriteRule ^(.*)$ https://%1$1 [R]

I guess you could have these directives at the server-level and use "RewriteOptions inherit"
in each VH.


-----Original Message-----
From: John Moore [] 
Sent: Friday, February 03, 2006 5:44 PM
Subject: Re: [users@httpd] Redirecting http traffic to an https virtual host


Here is what I have in production today on a Apache 2.0.X server.  This 
is within a VirtualHost.   Suggest defining a rewrite log and setting 
logging level high to see what's going on behind the scene if this doesn't work for you.


<Location "/xyz">
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !=443
    RewriteRule ^.*/xyz(.*)$ https://%{SERVER_NAME}/xyz$1 [R] </Location>

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