You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brian Akins <br...@turner.com> on 2006/06/01 21:36:40 UTC

[PATCH] add notfound to mod_rewrite rule

patch against 2.2.2 (but should work on most other versions).  Adds the 
"notfound" (NF) flag to rewriterule that will case it to return 
HTTP_NOT_FOUND for matched, similar to the gone and forbidden options.



--- mod_rewrite.c.bak   2006-06-01 15:25:48.000000000 -0400
+++ mod_rewrite.c       2006-06-01 15:29:18.000000000 -0400
@@ -3264,6 +3264,11 @@
              || !strcasecmp(key, "ocase")) {                /* nocase */
              cfg->flags |= RULEFLAG_NOCASE;
          }
+        else if (((*key == 'F' || *key == 'f') && !key[1])
+             || !strcasecmp(key, "otfound")) {           /* notfound */
+            cfg->flags |= (RULEFLAG_STATUS | RULEFLAG_NOSUB);
+            cfg->forced_responsecode = HTTP_NOT_FOUND;
+        }
          else {
              ++error;
          }


-- 
Brian Akins
Lead Systems Engineer
CNN Internet Technologies

Re: [PATCH] add notfound to mod_rewrite rule

Posted by André Malo <nd...@perlig.de>.
* Brian Akins wrote:

> 'redirect|R  [=code]' (force redirect)
> Prefix Substitution with http://thishost[:thisport]/ (which makes the
> new URL a URI) to force a external redirection. If no code is given, a
> HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want
> to use other response codes in the range 300-400, simply specify the
> appropriate number or use one of the following symbolic names: temp
> (default), permanent, seeother. Use this for rules to canonicalize the
> URL and return it to the client - to translate ``/~'' into ``/u/'', or
> to always append a slash to /u/user, etc.
>
>
> So do the docs need to be updated to say: return arbitrary http code?
>
> BTW, this does work.  patch withdrawn.  somebody needs to fix docs...

Yeah, good point. This could really need some better wording. ;)

nd
-- 
"Umfassendes Werk (auch fuer Umsteiger vom Apache 1.3)"
                                          -- aus einer Rezension

<http://pub.perlig.de/books.html#apache2>

Re: [PATCH] add notfound to mod_rewrite rule

Posted by Brian Akins <br...@turner.com>.
André Malo wrote:

> We don't need this, because you can use [R=404]. F and G are already just 
> syntactic sugar.
> 

 From the docs:

'redirect|R  [=code]' (force redirect)
Prefix Substitution with http://thishost[:thisport]/ (which makes the 
new URL a URI) to force a external redirection. If no code is given, a 
HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want 
to use other response codes in the range 300-400, simply specify the 
appropriate number or use one of the following symbolic names: temp 
(default), permanent, seeother. Use this for rules to canonicalize the 
URL and return it to the client - to translate ``/~'' into ``/u/'', or 
to always append a slash to /u/user, etc.


So do the docs need to be updated to say: return arbitrary http code?

BTW, this does work.  patch withdrawn.  somebody needs to fix docs...

-- 
Brian Akins
Lead Systems Engineer
CNN Internet Technologies

Re: [PATCH] add notfound to mod_rewrite rule

Posted by André Malo <nd...@perlig.de>.
* Brian Akins wrote:

> patch against 2.2.2 (but should work on most other versions).  Adds the
> "notfound" (NF) flag to rewriterule that will case it to return
> HTTP_NOT_FOUND for matched, similar to the gone and forbidden options.

We don't need this, because you can use [R=404]. F and G are already just 
syntactic sugar.

nd
-- 
"Umfassendes Werk (auch fuer Umsteiger vom Apache 1.3)"
                                          -- aus einer Rezension

<http://pub.perlig.de/books.html#apache2>