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.
-ascs
-----Original Message-----
From: John Moore [mailto:[EMAIL PROTECTED]
Sent: Friday, February 03, 2006 5:44 PM
To: [email protected]
Subject: Re: [EMAIL PROTECTED] Redirecting http traffic to an https virtual host
Peter,
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.
John
<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:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]