Image Hotlinking

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 6
Joined: 12 Jan 2013, 09:35

Image Hotlinking

12 Jan 2013, 09:39

I'm trying to work out where I've gone wrong. I am on a shared hosting site which I've been told has ISAPI Rewrite 3.1.0.87 is installed and am trying to prevent hotlinking from taking place. Every attempt at .htaccess file doesn't work. I stick the .htaccess file in the root directory of my website /httpdocs but still pictures can link to it. My .htaccess is :-

[ISAPI_Rewrite]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.co.uk [NC]
RewriteRule \.(jpg|jpeg|gif)$ - [NC,F,L]

What have I done wrong?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Image Hotlinking

12 Jan 2013, 12:00

The rule looks very good.
Make sure the ISAPI_Rewrite is working at all. try using a single testing rule like:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteRule ^test$ - [F]


Request the /test page and you should get FORBIDDEN. If not - contact your hosting. Sometimes hosting companies change the names of the config files for security reasons, so it may not be .htaccess in the first place.

Regards
Andrew

User avatar
Posts: 6
Joined: 12 Jan 2013, 09:35

Re: Image Hotlinking

12 Jan 2013, 22:15

Hmmm, working now but thanks for that pointer you gave earlier.

Didn't do anything, apart from add the "RewriteBase /" line, took that out then put it back in and worked both times, dunno if caching made any difference. Wonder if IIS cached the file between reads or does ISAPI read it on EVERY request. Would that line have made a difference?

For future reference if anyone reads this note, I suggest using http://www.htaccesstools.com/hotlink-protection/ as that website helped me loads.

Keep up the good work.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Image Hotlinking

13 Jan 2013, 09:24

It can be permissions issues. IIS_WPG group, for example, didn't have permissions to read the file everytime the changes are made.
If it happens in future, pls, make sure to follow this part of documentation.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 59 guests