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 37758] New: - mod_rewrite trailing slash problem on external redirect in per-dir context
Date Fri, 02 Dec 2005 17:28:37 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=37758>.
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=37758

           Summary: mod_rewrite trailing slash problem on external redirect
                    in per-dir context
           Product: Apache httpd-2.0
           Version: 2.0.55
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: caterham@web.de


When a sub directory was called without a trailing slash and RewriteRule was
placed into a .htaccess in that subdirectory, stripping of the per-dir prefix
fails and an external redirect does not work as expected.

-> The .htaccess is located at /test/.htaccess (which is
C:/apache/htdocs/test/.htaccess)

-> The URL called without the trailing slash is: http://localhost/test

first scenario - internal rewrite -- works fine (expected result is /cef/):

RewriteEngine on
RewriteRule (.*) /cef/$1 [L]

RewriteLog - loglevel 9
[rid#11c8e18/initial] (3) [per-dir C:/apache/htdocs/test/] applying pattern
'(.*)' to uri 'C:/apache/htdocs/test'
[rid#11c8e18/initial] (2) [per-dir C:/apache/htdocs/test/] rewrite
C:/apache/htdocs/test -> /cef/C:/apache/htdocs/test
[rid#11c8e18/initial] (1) [per-dir C:/apache/htdocs/test/] internal redirect
with /cef/C:/apache/htdocs/test [INTERNAL REDIRECT]
[rid#11cae20/initial] (3) [per-dir C:/apache/htdocs/test/] strip per-dir prefix:
C:/apache/htdocs/test/ -> 
[rid#11cae20/initial] (3) [per-dir C:/apache/htdocs/test/] applying pattern
'(.*)' to uri ''
[rid#11cae20/initial] (2) [per-dir C:/apache/htdocs/test/] rewrite  -> /cef/
[rid#11cae20/initial] (1) [per-dir C:/apache/htdocs/test/] internal redirect
with /cef/ [INTERNAL REDIRECT]

Due to the missing trailing slash, mod_rewrite fails to strip the per-dir prefix.
After the first (unexpected) internal redirect (rid#11c8e18) mod_dir acts and
responses with a 301 redirect to /test/. With rid#11cae20 mod_rewrite's
processing starts again, strips the  per-dir prefix correctly and performs an
internal redirect to the expected URL /cef/.

second scenario - external redirection -- does not work (expected result is
external redirect to /cef/):

RewriteEngine on
RewriteRule (.*) /cef/$1 [R,L]

RewriteLog - loglevel 9
[rid#11826c0/initial] (3) [per-dir C:/apache/htdocs/test/] applying pattern
'(.*)' to uri 'C:/apache/htdocs/test'
[rid#11826c0/initial] (2) [per-dir C:/apache/htdocs/test/] rewrite
C:/apache/htdocs/test -> /cef/C:/apache/htdocs/test
[rid#11826c0/initial] (2) [per-dir C:/apache/htdocs/test/] explicitly forcing
redirect with http://localhost/cef/C:/apache/htdocs/test
[rid#11826c0/initial] (1) [per-dir C:/apache/htdocs/test/] escaping
http://localhost/cef/C:/apache/htdocs/test for redirect
[rid#11826c0/initial] (1) [per-dir C:/apache/htdocs/test/] redirect to
http://localhost/cef/C:/apache/htdocs/test [REDIRECT/302]

The same case: Due to the missing trailing slash, mod_rewrite fails to strip the
per-dir prefix and matches the RegEx against the full physical filepath. This
time mod_dir does not act and does not send the trailing slash. So the URL
returned to the client is http://localhost/cef/C:/apache/htdocs/test and not the
expected URL http://localhost/cef/.

Of course a workaround is to place the rules into /.htaccess.

-- 
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