You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jan Kaluža <jk...@redhat.com> on 2013/09/13 08:00:26 UTC

[PATCH] mod_rewrite, mod_dir and RewriteRule ^$

Hi,

I was trying to examine and fix PR 53929. The problem is that rewrite 
rule "RewriteRule ^$ /index-cached.html [L]" with "GET /" worked as 
expected in httpd-2.2, but in httpd-2.4 it does not because of following 
mod_dir commit: <http://svn.apache.org/r233369>.

This commit was originally trying to fix PR 25435, but it does not fix 
this PR completely. Proper fix is described in PR 25435, but the patch 
is not implemented and the proposed solution with SetDirHandler and 
SetFileHandler is not acceptable for 2.4 probably.

I'm trying to fix PR 53929 with attached patch. Normally r->uri and 
r->filename ends with "/" in the case of directory request. If 
mod_rewrite rewrites URL in hook_fixup, it changes r->filename. In this 
patch, I check if the r->filename still ends with "/" and if not, return 
DECLINED in mod_dir fixup hook.

However, I think there is still problem if you rewrite r->filename from 
directory to directory, but it should fix case when you rewrite from 
directory to file. I don't see immediate solution for directory to 
directory rewrite, so any help is welcome.

I have tested the patch and run test-suite without noticing any regression.

Regards,
Jan Kaluza

Re: [PATCH] mod_rewrite, mod_dir and RewriteRule ^$

Posted by Jan Kaluza <jk...@redhat.com>.
----- Original Message -----
> > I'm trying to fix PR 53929 with attached patch. Normally r->uri and
> > r->filename ends with "/" in the case of directory request. If mod_rewrite
> > rewrites URL in hook_fixup, it changes r->filename. In this patch, I check
> > if the r->filename still ends with "/" and if not, return DECLINED in
> > mod_dir fixup hook.
> 
> Hope to look more this weekend, but I was surprised in context that we
> wouldn't hit the DirectorySlash case just above where your patch kicks
> in.  Doesn't rewrite change both in fixups?  Just asking in case
> you've explored this already -- thanks.
> 

mod_rewrite changes only r->filename and keeps r->uri unchanged in fixup function.
I have no idea if that's correct behaviour right now.

Regards,
Jan Kaluza

Re: [PATCH] mod_rewrite, mod_dir and RewriteRule ^$

Posted by Eric Covener <co...@gmail.com>.
> I'm trying to fix PR 53929 with attached patch. Normally r->uri and
> r->filename ends with "/" in the case of directory request. If mod_rewrite
> rewrites URL in hook_fixup, it changes r->filename. In this patch, I check
> if the r->filename still ends with "/" and if not, return DECLINED in
> mod_dir fixup hook.

Hope to look more this weekend, but I was surprised in context that we
wouldn't hit the DirectorySlash case just above where your patch kicks
in.  Doesn't rewrite change both in fixups?  Just asking in case
you've explored this already -- thanks.