mod_rewrite

The ability to redirect, set environment variables, apply access controls and perform other data transformations that mod_rewrite provides allows us to put logic in the server that we otherwise would be forced to perform with a CGI or a one-off home grown module.

Here is an example of using mod_rewrite to provide QUERY_STRING based navigation without the use of an external program (i.e. a CGI, etc). In httpd.conf we add the following directives:

RewriteEngine On
RewriteMap unescape-chars int:unescape
RewriteCond %{QUERY_STRING} location=(.*)
RewriteRule ^/locations.* ${unescape-chars:%1}? [L,R] 
Using mod_rewrite's unescape function we can filter data through Apache's native URL escaping facility so hex-escaped data comes out transformed in the clear. So let's look at some HTML we could have make use of this.
Slide 10 of 19 Contents
  1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 | 10
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
www.arachna.com > Educational Resources > Conference Presentations

spidaman
© 1999-2008 Ian Kallen | Copyright Notice