Received: by taz.hyperreal.com (8.7.5/V2.0) id KAA25510; Fri, 16 Aug 1996 10:09:33 -0700 (PDT) Received: from colin.muc.de by taz.hyperreal.com (8.7.5/V2.0) with SMTP id KAA25490; Fri, 16 Aug 1996 10:09:20 -0700 (PDT) Received: from en by colin.muc.de with UUCP id <86017-2>; Fri, 16 Aug 1996 19:08:51 +0200 Received: by en.muc.de (Sendmail5.67a8/IDA-1.5) id AA02564; Fri, 16 Aug 1996 19:07:26 +0200 Message-Id: <199608161707.AA02564@en.muc.de> Subject: FYI: mod_rewrite v2.2-SNAP changes To: new-httpd@hyperreal.com (Apache Developer ML) Date: Fri, 16 Aug 1996 19:07:25 +0200 From: rse@engelschall.com (Ralf S. Engelschall) Organization: Engelschall Private, Dachau/Munich, Germany X-W3-Page: http://www.engelschall.com/~rse X-Mailer: ELM [version 2.4 PL22] Content-Type: text X-Charset: ASCII X-Char-Esc: 29 Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com 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 1.2.3.4. 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/foopath.pl RewriteRule ^/foo/(.*)$ /foo/${foopath-map:$1} foopath.pl ------------------------------------ #!/usr/local/bin/perl $| = 1; while (<>) { s|bar|quux|; print $_; } ------------------------------------ This will fork foopath.pl once when Apache starts up and then mod_rewrite will communicate through the stdin/stdout filehandles of foopath.pl 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 escape! Now I get tired of enhancing the hackers world... Greetings, Ralf S. Engelschall rse@engelschall.com http://www.engelschall.com/~rse 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...