Forum Moderators: phranque

Message Too Old, No Replies

conditional rewrite rules possible?

Need Help to understand please

         

Inny

6:51 pm on Apr 25, 2011 (gmt 0)

10+ Year Member



Hi people,
I've been exploring .htaccess use to prevent hotlinking.

At present my code is

Options +FollowSymLinks
## DISABLE HOTLINKING
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?camosreptiles.com.au(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|png|jpeg|bmp)$ http://www.camosreptiles.com.au/hotlink.shtml [R,NC]


1. If an image address from my server is typed in the address bar of a browser, its redirected to /hotlink.shtml which explains hotlinking and links to my domain.

This is good.

2. If somebody requests a full sized image from google, (which by default shows a cached thumb then goes to my domain), instead of waiting for googles redirect, it redirects to
/hotlink.shtml.

This is good.

3. If somebody adds an image from my domain on their own using tags, they get a broken image icon (chrome).

This is ok but Id like, if possible, to have a conditional rewrite rule to deal with #3. For number #3 Id like to show them a 'hotlink.jpeg' instead.

Is that possible? I know how to code to show 'hotlink.jpeg'
instead, but not both.

wilderness

2:07 pm on Apr 26, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



1. If an image address from my server is typed in the address bar of a browser, its redirected to /hotlink.shtml which explains hotlinking and links to my domain.


There are hundreds (perhaps thousands) of examples of these anti-hot-linking lines here at Webmaster and across the internet.

Your understanding of how the lines you provide work are not correct.
The lines you've provided DO NOT stop direct requests.
The lines you provided only stop requests in which a referring link from another website is provided in the request.
Refer based denials are certainly not 100% effective, although they have their use.
Direct requests require PHP or some other type of script.

if possible, to have a conditional rewrite rule to deal with #3. For number #3 Id like to show them a 'hotlink.jpeg' instead.


This is a bad practice (at least from an administrational point-of-view) and will only challenge the pests to improve their skills to circumvent your misunderstndings.

The most accepted practice is to simply deny (403) access.