----- "Stefan Fritsch" <[email protected]> wrote: > On Wednesday 29 December 2010, Andrew Farmer wrote: > > On 29 Dec 2010 at 01:25, Igor Galić wrote: > > > Please share your particularly ugly, involved, unaesthetic or > > > otherwise /wrong/ solutions done with mod_rewrite because it > > > was the only hammer available for the screws at that time ;) > > > > I came up with the following abomination a while back to disable > > hotlinking to files when the referrer doesn't match the request > > host (in > > > > conjunction with a setup that amounts to wildcard DNS): > > > RewriteEngine on > > > RewriteCond %{HTTP_REFERER} ://([^/]+)/ > > > RewriteRule . - [E=RHOST:%1] > > > > > > RewriteCond %{REQUEST_URI} ^/(albums|cache)/ > > > RewriteCond %{ENV:RHOST} !^$ > > > RewriteCond %{HTTP_HOST}:%{ENV:RHOST} !^([^:]*):(\1)$ > > > RewriteRule . - [F]
The image theft example was pretty much the first Paul has given us: http://journal.paul.querna.org/articles/2008/12/23/mod_lua-in-apache-trunk/ > > The observant will notice a novel abuse of regex backreferences > > used here to implement string comparison. A reimplementation of > > the same configuration in Lua should be able to avoid this. :) > > Not what Igor wanted, but this could be simplified a lot by using the So not true ;) I've been wondering for months now if we couldn't use the new expression parser to simplify mod_rewrite and make it more accessible to the masses > shiny new ability of RewriteCond to use ap_expr: > > RewriteCond %{REQUEST_URI} ^/(albums|cache)/ > RewriteCond expr "%{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'" > RewriteRule . - [F] That's pretty cool. > BTW, is it possible to implement rewrite maps with mod_lua? I think it > would be an interesting application of mod_lua if it could be used to > add rewrite map functions, and ap_expr functions and operators. +1 i -- Igor Galić Tel: +43 (0) 664 886 22 883 Mail: [email protected] URL: http://brainsware.org/
