How To Preventing Hot Linking Of Images And Other File Types


Subject: How To Preventing Hot Linking Of Images And Other File Types
Hi there,

After looking at my sites referres I was a little pissed off that some clever guy is hotlinking to my site. After looking around for a solution I found that .htaccess is probably the easiest to implement.

Simply add the below code to your .htaccess file, and upload the file either to your root directory, or a particular subdirectory to localize the effect to just one section of your site:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mydomain.com/.*$ [NC]
RewriteRule .(gif|jpg|js|css)$ - [F]


Be sure to replace "mydomain.com" with your own. The above code creates a failed request when hot linking of the specified file types occurs. In the case of images, a broken image is shown instead.

Now for the tricky part where I need help

If "the clever guy" uses this particular link: http://www.icyphoenix.com/image_thu...4237_212683.png

the script doesnt work. Now the only way this link i generated is if you right clik an image and view it in your browser, if you note the url is kinda generated twice... :roll: But if someone tries to hotlink the image through the original link: http://www.icyphoenix.com/files/ima...4237_212683.png then the script does it's job nicely.

Can MG or someone come up with a solution for this :idea:

Subject: Re: How To Preventing Hot Linking Of Images And Other File T
You should perform the check even on the Query String...

Use this to refer to the Query String:
Code: [Download] [Hide] [Select]
{QUERY_STRING}


You can then make the same checks you were performing on {HTTP_REFERER}.


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.1874s (PHP: 9% SQL: 91%)
SQL queries: 10 - Debug Off - GZIP Enabled