[thelist] Apache and RewriteMap

Tony Brandner tony at serebra.com
Thu Nov 24 15:35:55 CST 2005


Hi all.
Man, you have to love Apache mod_rewrite. I get a chuckle from the quotes
comparing mod_rewrite to sendmail and voodoo.

I'm considering using rewrite to protect some course content on our server.
I managed to get a good pattern for a prototype in my RewriteRule, but I'm
having trouble getting RewriteMap to work.

Trying to make a daily map of student licenses so that links like this:
http://domain/123456789/launch.html
Map over (server side) to a URL that would be more equivalent to:
http://domain/path/to/course/launch.html

I'm using a RewriteMap called 'sessionmap.txt'. It lives in /var/www and has
mode 777
# in httpd.conf at config level
RewriteEngine on
RewriteMap sessionmap txt:/var/www/sessionmap.txt

# in httpd.conf at virtualhost level
RewriteEngine on
RewriteRule ^/ss/123456789/?(.*) /path/to/course/$1
RewriteRule ^/ss/([^/]*)/?(.*) ${sessionmap:$1|/test/}/$2
RewriteLog "/var/log/httpd/web_rewrite_log"
RewriteLogLevel 1

$ cat sessionmap.txt
##  sessionmap.txt -- rewriting map
##

234567890 /path/to/course/

When I run the link with 123456789, hardcoded into httpd.conf, it works
great.
When I run the link with 234567890, from sessionmap, no dice.

This matches, based on the first rule:
http://domain/ss/123456789/course.htm?key1=val1
The log file shows server-side redirect to
/wbt/path/to/course/course.htm?key1=val1
CORRECT, but not from sessionmap

This doesn't match my mapping document:
http://domain/ss/234567890/course.htm?key1=val1
The log file shows server-side redirect to /test/course.htm?key1=val1
INCORRECT

Anyone have any tips about where I can look?

Thanks,

Tony Brandner
Serebra Learning Corporation
www.serebra.com, www.easylearning.org




More information about the thelist mailing list