Image Hotlinking
4 posts
• Page 1 of 1
- MisterDeveloper
- Posts: 6
- Joined: 12 Jan 2013, 09:35
Image Hotlinking
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?
[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?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Image Hotlinking
The rule looks very good.
Make sure the ISAPI_Rewrite is working at all. try using a single testing rule like:
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
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
- MisterDeveloper
- Posts: 6
- Joined: 12 Jan 2013, 09:35
Re: Image Hotlinking
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Image Hotlinking
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
If it happens in future, pls, make sure to follow this part of documentation.
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 59 guests