httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Ralf S. Engelschall)
Subject FYI: mod_rewrite v2.2-SNAP changes
Date Fri, 16 Aug 1996 17:07:25 GMT

Just FYI mod_rewrite hackers: 

I lot of requests arrived at my private mailfolder for mod_rewrite.  Some
hackers out there are already using mod_rewrite v2.2-SNAP on their Websites
and gave good feedback. I added another bulk of major enhancements:
1. Now there is a "forbidden|F" flag which enabled us to emulate the recently
   posted mod_block idea (sorry, Alexei, I couldn't resist ;-): 

     RewriteCond %{HTTP_REFERER}         !.*/page-with-gif\.html$
     RewriteRule ^inlined-in-page\.gif$  -                        [F]

   This will block all requests for inlined-in-page.gif with a Referer:
   header which not ends in "/page-with-gif\.html". I think this will fully
   replace mod_block. And it provides even more features:

     RewriteCond %{REMOTE_ADDR}         ^1\.2\.3\.4$
     RewriteRule ^security-page\.html$  -            [F]

   This will block all access to security-page from IP-address
   Or for the robot haters under us ;-) :

     RewriteCond %{HTTP_USER_AGENT} ^HatedFooRobot.*
     RewriteRule ^page\.html$       -                [F]

2. Because of the problematic ("\\" for "\" etc.) argument
   parsing in 1.1.x mod_rewrite still does its own processing for RewriteCond
   and RewriteRule where the regexps occur. But it had no support for quoted
   args "xxx x x x x". Now it has...

3. Now you there is another RewriteMap filetype: "prg" - for programs.  With
   this you can setup ``dynamic maps'', i.e. a program which acts like a map.
   The program gets one key per lookup on stdin and has to provide the value
   as one line on stdout.  If it want to say "no value found" it just has to
   return the string(!) "NULL". An example:

     RewriteMap  foopath-map  prg:/usr/local/lib/apache/maps/
     RewriteRule ^/foo/(.*)$  /foo/${foopath-map:$1}
     $| = 1;
     while (<>) {
         print $_;

   This will fork once when Apache starts up and then mod_rewrite
   will communicate through the stdin/stdout filehandles of with
   the "map". In the silly example above this will e.g. rewrite /foo/bar/test
   to /foo/quux/test.

   Notice! This is similar to the URL-redirection programs of Squid where I
   had stolen the idea. It is only a per-server config feature because
   RewriteMap is only valid there! So, we have no problem with such maps,
   because no user can force Apache to fork such a beast. But for the admins
   who want to do very complicated URL rewriting this finally provides their

Now I get tired of enhancing the hackers world...

                                        Ralf S. Engelschall    

BTW: I tested the current v2.2-SNAP under 1.1.1 and 1.2-dev of today.
     It worked fine for my examples. If anyone want, he could commit it to
     the CVS tree...

View raw message