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
diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c
index 4364ff9..a09c6098 100644
--- a/modules/mappers/mod_dir.c
+++ b/modules/mappers/mod_dir.c
@@ -260,6 +260,11 @@ static int fixup_dir(request_rec *r)
         return HTTP_MOVED_PERMANENTLY;
     }
 
+    if (r->filename == 0 || r->filename[0] == '\0'
+            || r->filename[strlen(r->filename) - 1] != '/') {
+        return DECLINED;
+    }
+
     if (d->index_names) {
         names_ptr = (char **)d->index_names->elts;
         num_names = d->index_names->nelts;

Reply via email to