Project

General

Profile

is it possible to do some simple math before rewriting in lighttpd config?

Added by krisen over 4 years ago

I'm currently doing this in Apache, but I wish to switch to Lighttpd if possible. I am using RewriteMap and a simple perl script in Apache to support an old file structure on a static file web server;

RewriteMap archive-map prg:/www/scripts/archive_map.pl
RewriteCond %{REQUEST_URI} !^/archive/([0-9]+)/([0-9]+)/([0-9]+)/(.*?)$ [NC]
RewriteRule ^/archive/([0-9]+)/(.*?)$ /archive/${archive-map:$1}/$1/$2 [L]

This uses a super simple perl script (archive_map.pl) to calculate the new folder name based on a regex input. Basically it rewrites "/archive/1234/56/asdf.jpg" to "/archive/XX/1234/56/asdf.jpg" where XX is calculated by archive_map.pl from "1234" as input.

Is it possible to achieve the same thing some how in lighttpd?

Regards


Replies (1)

RE: is it possible to do some simple math before rewriting in lighttpd config? - Added by gstrauss over 4 years ago

You can use lua to do a wide set of arbitrary transformations inside lighttpd for each request.

Docs_ModMagnet
Absoluation

    (1-1/1)