httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 40737] New: - mod_rewrite rewritecond does not support %{} variables in the CondPattern
Date Thu, 12 Oct 2006 04:11:11 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40737>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40737

           Summary: mod_rewrite rewritecond does not support %{} variables
                    in the CondPattern
           Product: Apache httpd-2
           Version: 2.0.54
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: mod_rewrite
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: mbuchmann@shaw.ca


I'm attempting to do a basic rewrite to force all hits to a consistent URI,
i.e.:   IP-only hits, miXedCase hostnames, http://etc.. hits are all redirected
to a consistent https://www.example.com/


My server configuration/rewrite rules are as follows:

  ServerName www.example.com
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^%{SERVER_NAME}$ [OR]
  RewriteCond %{SERVER_PORT] !^443$
  RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R=301]

Attempting a hit on https://wWw.exAMPLe.COm produces the following log entry

(4) RewriteCond: input='wWw.exAMPLe.COm' pattern='!^%{SERVER_NAME}$' => matched
(2) rewrite / -> https://www.example.com/
(2) explicitly forcing redirect with https://www.example.com/

and then we enter into an infinite redirection loop, as the HTTP_HOST will never
match the literal string '%{SERVER_NAME}'. Rewriting the Cond rule as

  RewriteCond %{HTTP_HOST} !^www.example.com$ [OR]

solves the redirect, as the rule match will fail when the HTTP_HOST properly
matches the SERVER_NAME.

Enabling expansion of %{} variables in the CondPattern would allow writing
generic rules (as I attempted above) which could be slurped in at various places
in the .conf files using Include, without having to customize them for each and
every vhost requiring such redirection.


This was all done on a RedHat Enterprise 4 ES (Nahant Update 4) server, with
FireFox 1.5.0.7 as the client and Apache 2.0.52-28 (most recent up2date
version). Problem should be consistent across all version of Apache and mod_rewrite.

Thanks for your time.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message