Fun with mod_rewrite
by jcf. Average Reading Time: less than a minute.
I don’t like people deep-linking to my images. And neither do others. Some quick mod_rewrite rules helps…
I noticed an increased activity on my blog and a lot of referres from an italian site recently. Today I had time to look at the logs and I found a site that linked to my Gicaometti image.
I didn’t like that too much, so I googled a bit and found ChaosReigns cure. He excluded everybody from deep linking, but I only wanted to make the point to this one person.
After some experiments with mod_rewrite, here’s my newest inclusion in httpd.conf:
RewriteEngine On
RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 7
RewriteCond %{HTTPREFERER} ^http://.*splinder.it/.*$ RewriteCond %{REQUESTURI} !^/bad.jpg$ [NC] RewriteRule .*.(gif|jpg|png|bmp)$ /bad.jpg [NC,R,L]
Of course bad.jpg looks really nasty ;-) (and I stole it shamelessly from Chaos Reigns. At least I copied it to my server first ;-)

No comments on ‘Fun with mod_rewrite’
Leave a Reply