Project

General

Profile

Feature #2358

Check if directory exists in url.rewrite-if-not-file

Added by unikum almost 9 years ago. Updated over 4 years ago.

Status:
Invalid
Priority:
Normal
Category:
mod_rewrite
Target version:
-
ASK QUESTIONS IN Forums:

Description

Like this it would be nice is realize directory exist check.

Regards...

#1

Updated by unikum almost 9 years ago

  • Target version set to 1.4.x
#2

Updated by gstrauss over 4 years ago

  • Subject changed from Check if directory exists in url.rewrte-if-not-file to Check if directory exists in url.rewrite-if-not-file
  • Status changed from New to Patch Pending
diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c
index fac6c49..2a394b5 100644
--- a/src/mod_rewrite.c
+++ b/src/mod_rewrite.c
@@ -463,7 +463,7 @@ URIHANDLER_FUNC(mod_rewrite_physical) {
        /* skip if physical.path is a regular file */
        sce = NULL;
        if (HANDLER_ERROR != stat_cache_get_entry(srv, con, con->physical.path, &sce)) {
-               if (S_ISREG(sce->st.st_mode)) return HANDLER_GO_ON;
+               if (S_ISREG(sce->st.st_mode) || S_ISDIR(sce->st.st_mode)) return HANDLER_GO_ON;
        }

        switch(r = process_rewrite_rules(srv, con, p, p->conf.rewrite_NF)) {
#3

Updated by gstrauss over 4 years ago

  • Target version changed from 1.4.x to 1.4.40
#4

Updated by stbuehler over 4 years ago

No! This breaks clearly documented behavior. url.rewrite-if-not-file checks for regular file, not for directories.

#5

Updated by gstrauss over 4 years ago

  • Status changed from Patch Pending to Invalid

Quoting from https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRewrite:

url.rewrite-[repeat-]if-not-file

New: For the 1.4.x branch as of 1.4.24 or r2647 from svn:

Rewrites a set of URLs internally in the webserver BEFORE they are handled and checks that files do not exist.

Take examples from above, this is to mimic ApacheĀ“s "!-f" RewriteRule. Please note this does not work for directories, pipes, sockets or alike.

Where do I want to use this? Maybe with e.g. Drupal backend, where mod_magnet (has an ApacheĀ“s -f and -d solution) might not be handy or simply "too much" for just this kind of rewrites. This closes feature request #985.

#6

Updated by stbuehler over 4 years ago

Just for the record: I'm not saying a feature request for a similar rewrite action checking for directories would be wrong; although I see some challenges in defining the execution order of multiple rewrite-if-not{file,directory,exists,...} options.

#7

Updated by stbuehler over 4 years ago

  • Target version deleted (1.4.40)

Also available in: Atom