General Community > Scripting Help
Hot Linking Help
Ben_S:
I want to disallow hotlinking via a certain site, but allow it from all other sites.
All the things I can find about it though refer to disalowing hotlinking from all sites, not just certain domains.
Any pointers?
Ps should mention, I would like to display a different image rather than a red cross
Peter Duggan:
Well, I found code to this effect somewhere when I was having trouble with the normal rewrite rule method:
--- Code: ---SetEnvIfNoCase Referer "^http://www.simplemachines.org/" locally_linked=1
SetEnvIfNoCase Referer "^http://simplemachines.org/" locally_linked=1
SetEnvIfNoCase Referer "^$" locally_linked=1
<FilesMatch "\.(gif|png|jpe?g)$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch>
--- End code ---
Can't remember where I got it from, but it works and you can add sites one by one.
<edit>Reply posted before I saw Ben's edit!</edit>
Nemesis:
should be able to do that via htaccess
not sure how cause I don't have the time to look it up, but just do a search on that.
Ben_S:
Yeah, can done done with .htaccess/mod rewrite, just a case of coming up with some appropriate rules ;D
Will have a look on some geeky apache type forums later ;D
Aquilo:
what Peter Duggan posted is .htaccess!
that is a preferred structure these days.
every thing you seen for disallowing hotlinking has been what you wanted just take out the little exclamation mark '!'
in this example any board on would be send to the nearest HTTP Error 403 - Forbidden page
--- Code: ---RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(.*)\.proboards(.*)\.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]
--- End code ---
same code can you spot what now allows only proboards to access the content?
--- Code: ---RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.*)\.proboards(.*)\.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]
--- End code ---
it is the same concept as php and other languages the exclamation mark '!' means DOES NOT
<?php
if ($username != 'Aquilo')
exit;
?>
here is a site packed full of examples meanings to every thing even what the flags mean as-in: [F] = Forbidden && [NC] = NO CASE = it's not case sencitive
http://httpd.apache.org/docs/howto/htaccess.html
there are more version then 1.3 so hunt around
Navigation
[0] Message Index
[#] Next page
Go to full version