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] - mod_rewrite trailing slash problem on external redirect in per-dir context
Date Mon, 05 Dec 2005 21:03:10 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





------- Additional Comments From johndstrunk@gmail.com  2005-12-05 22:03 -------
(In reply to comment #0)
> 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.


I get a simmilar problems with mod_rewrite in the virtual host definitions on
linux distributions as well.

HTTPS vhost:
RewriteRule ^/subdirectory/(.*)$  /$1 [C]
RewriteRule ^/(.*)$    http://www.mydomain.com:8080/subdirectory/$1  [P,L]

In FireFox, I dont seem to have an issue as frequently (maby becuase it occurs
on new sessions only), but with IE I get upredictable results; sometimes it
works, sometimes it doesn't, after the first failed and segfaulting child the
next one works, sometimes it takes multiple tries and child processes dying and
finnally works.  Wget also has an issue and sometimes it works right off, other
times it takes multiple tries with child procs segfaulting.

the core dump I get is:

#0  0x403da8c7 in memcpy () from /lib/libc.so.6
#1  0x4054d6cf in do_expand (r=0x824aa08, input=0x8137c08 "/SchedWorx/$1",
    buffer=0xbfffb850 "/subdirectory/", nbuf=8192, briRR=0x824bf50,
    briRC=0x824bfa8) at mod_rewrite.c:2576
#2  0x4054c655 in apply_rewrite_rule (r=0x824aa08, p=0x8137d68, perdir=0x0)
    at mod_rewrite.c:2156
#3  0x4054c0ed in apply_rewrite_list (r=0x824aa08, rewriterules=0x81378b8,
    perdir=0x0) at mod_rewrite.c:1843
#4  0x40553296 in hook_uri2file (r=0x824aa08) at mod_rewrite.c:1190
#5  0x08080513 in ap_process_request_internal (r=0x824aa08) at request.c:65
#6  0x080660b9 in ap_process_request (r=0x824aa08) at http_request.c:247
#7  0x08060ffb in ap_process_http_connection (c=0x8242948) at http_core.c:251
#8  0x080737d8 in ap_process_connection (c=0x8242948, csd=0x8242870)
    at connection.c:43
#9  0x080685d3 in child_main (child_num_arg=8179) at prefork.c:610
#10 0x080679bc in make_child (s=0xbfffb85b, slot=6) at prefork.c:704
#11 0x08067517 in ap_mpm_run (_pconf=0x6, plog=0x80cf348, s=0x2)
    at prefork.c:722
#12 0x0806e85a in main (argc=3, argv=0xbfffdf44) at main.c:618


>From what I can understand is that mod_rewrite.c failes with an out of mem
access and fails.  (mem leak bug?)

I can understand maby the rules are wrong, but that should not *crash* Apache.

This is with and without the applyed patch of 37145_2.0.x.diff for which I had
other issues with uploading files via proxy_http.c


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