httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1209053 - in /httpd/httpd/trunk: docs/manual/mod/mod_rewrite.xml modules/mappers/mod_rewrite.c
Date Thu, 01 Dec 2011 12:40:53 GMT
Author: minfrin
Date: Thu Dec  1 12:40:51 2011
New Revision: 1209053

URL: http://svn.apache.org/viewvc?rev=1209053&view=rev
Log:
mod_rewrite: Add the AllowNoSlash RewriteOption, which makes it possible
for RewriteRules to be placed in .htaccess files that match the directory
with no trailing slash. PR 48304.

Modified:
    httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml
    httpd/httpd/trunk/modules/mappers/mod_rewrite.c

Modified: httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml?rev=1209053&r1=1209052&r2=1209053&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_rewrite.xml Thu Dec  1 12:40:51 2011
@@ -171,6 +171,21 @@ later</compatibility>
       Available in Apache HTTP Server 2.3.10 and later.</p>
       </dd>
 
+      <dt><code>AllowNoSlash</code></dt>
+      <dd>
+      <p>By default, <module>mod_rewrite</module> will ignore URLs that
map to a
+      directory on disk but lack a trailing slash, in the expectation that
+      the <module>mod_dir</module> module will issue the client with a redirect
to
+      the canonical URL with a trailing slash.</p>
+      
+      <p>When the <directive module="mod_dir">DirectorySlash</directive>
directive
+      is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
+      that rewrite rules are no longer ignored. This option makes it possible to
+      apply rewrite rules within .htaccess files that match the directory without
+      a trailing slash, if so desired. Available in Apache HTTP Server 2.4.0 and
+      later.</p>
+      </dd>
+
       </dl>
 
 </usage>

Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=1209053&r1=1209052&r2=1209053&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Thu Dec  1 12:40:51 2011
@@ -189,6 +189,7 @@ static const char* really_last_key = "re
 #define OPTION_NONE                 1<<0
 #define OPTION_INHERIT              1<<1
 #define OPTION_INHERIT_BEFORE       1<<2
+#define OPTION_NOSLASH              1<<3
 
 #ifndef RAND_MAX
 #define RAND_MAX 32767
@@ -2882,6 +2883,9 @@ static const char *cmd_rewriteoptions(cm
         else if (!strcasecmp(w, "inheritbefore")) {
             options |= OPTION_INHERIT_BEFORE;
         }
+        else if (!strcasecmp(w, "allownoslash")) {
+            options |= OPTION_NOSLASH;
+        }
         else if (!strncasecmp(w, "MaxRedirects=", 13)) {
             ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
                          "RewriteOptions: MaxRedirects option has been "
@@ -4698,9 +4702,10 @@ static int hook_fixup(request_rec *r)
     /*
      *  .htaccess file is called before really entering the directory, i.e.:
      *  URL: http://localhost/foo  and .htaccess is located in foo directory
-     *  Ignore such attempts, since they may lead to undefined behaviour.
+     *  Ignore such attempts, allowing mod_dir to direct the client to the
+     *  canonical URL. This can be controlled with the AllowNoSlash option.
      */
-    if (!is_proxyreq) {
+    if (!is_proxyreq && !(dconf->options & OPTION_NOSLASH)) {
         l = strlen(dconf->directory) - 1;
         if (r->filename && strlen(r->filename) == l &&
             (dconf->directory)[l] == '/' &&



Mime
View raw message