httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Smith" <>
Subject Adding an md5 function to mod_rewrite
Date Mon, 15 Jan 2007 09:25:51 GMT
I would like to propose a small (10 line) patch to mod_rewrite to add an md5
internal function.

Why is this useful?  Well, indeed is it useful?  In my case I am serving
content which is based entirely on the REFERER.  I am using mod_rewrite to
determine if I've already created a file for that referer (yes it's a bit of
a dirty way of caching I know), with something like this:

        RewriteCond /cache/${md5:%{HTTP_REFERER}}.html -f
        RewriteRule ^/document.html$ /cache/${md5:%{HTTP_REFERER}}

If the document doesn't exist, I fall back to my regular script, which
creates the file so it'll be found next time.

I've found that the escape method can't be used for this purpose, as it
doesn't encode all the necessary characters (a few people have commented on

I hope that adding this function will help in other cases too, though to be
honest I can't think of them at the moment!



>       map_pfn_register("md5", rewrite_mapfunc_md5);
> static char *rewrite_mapfunc_md5(request_rec *r, char *key)
> {
>       char *value;
>       value = ap_md5(r->pool, key);
>       return value;
> }

> static char *rewrite_mapfunc_md5(request_rec *r, char *key);

View raw message