RE: [users@httpd] Redirecting http traffic to an https virtual host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:johnmoore@xxxxxxxxxxxxxxxxx] 
Sent: Friday, February 03, 2006 5:44 PM
To: users@xxxxxxxxxxxxxxxx
Subject: Re: [users@httpd] 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: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux