Please note that you may have been redirected (you might like to make a note of the URL in the address bar of your browser and update accordingly) This is a permanent archvie but is no longer actively maintained. Please visit http://joshuaink.com for the latest updates.
Prevent hotlinking with Textpattern RC3
Wednesday March 30, 2005
Just a quick one for Textpattern RC3 users. After a thought by Sebastian about how costly it would be if someone decided to hotlink to my header image, I did a bit of Googling and found a solution, hopefully.
The code shown below takes the default .htaccess file distributed with Textpattern RC3 and adds three lines of code (lines 2 to 4). The order is important, I crashed my site so you don't have to! Obviously you will need to change the domain name on line 3 to your own.
There are options given in the original tutorial for presenting a default image to bandwidth thieves but I wonder if that kind of defeats the purpose a little, the code below just delivers nothing.
- RewriteEngine On
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com(/)?.*$ [NC]
- RewriteRule .*\.(gif|jpe?g|png|bmp)$ [F,NC]
- RewriteCond %{REQUEST_FILENAME} -f [OR]
- RewriteCond %{REQUEST_FILENAME} -d
- RewriteRule ^(.+) - [PT,L]
- RewriteRule ^(.*) index.php
I am no mod_rewrite expert, so any feedback, or reports of successful hotlinking would be much appreciated.




Rob McMichael
1809 days ago
AkaXakA
1809 days ago
AkaXakA
1809 days ago
jordan
1809 days ago
jordan
1809 days ago
Dave
1809 days ago
AkaXakA
1809 days ago
Eric Irvine
1809 days ago
Eric Irvine
1809 days ago
jordan
1809 days ago
AkaXakA
1808 days ago
AkaXakA
1808 days ago
jordan
1807 days ago
Lynn
1502 days ago