Log in

View Full Version : Attachment.php hotlinking


GlitterKill
02-10-2005, 02:37 PM
How can I keep people from hotlinking to attachments? I already stop hotlinks for images. I cannot simply add php to the set since it will prevent people from linking to our article which are php as well.

Any ideas how to keep attachment.php specifically from being hotlinking from outside the domain?

I figured it out... here is the code I used in .htaccess to prevent hotlinking for attachment.php and avatar.php


<FilesMatch "attachment\.php">
ErrorDocument 403 http://mydomain.com/sorry.gif
SetEnvIf Referer "^http://www\.pimprig\.com" good_referal
SetEnvIf Referer "^http://pimprig\.com" good_referal
SetEnvIf Referer "^http://forums\.pimprig\.com" good_referal
SetEnvIf Referer "^http://gallery\.pimprig\.com" good_referal
SetEnvIf Referer "^http://links\.pimprig\.com" good_referal
SetEnvIf Referer "^http://reviews\.pimprig\.com" good_referal
SetEnvIf Referer "^http://guides\.pimprig\.com" good_referal
SetEnvIf Referer "^http://systems\.pimprig\.com" good_referal
SetEnvIf Referer "^http://articles\.pimprig\.com" good_referal
SetEnvIf Referer "^http://news\.pimprig\.com" good_referal
SetEnvIf Referer "^http://team\.pimprig\.com" good_referal
SetEnvIf Referer "^$" good_referal

Order Deny,Allow
Deny from all
Allow from env=good_referal
</FilesMatch>
<FilesMatch "avatar\.php">
ErrorDocument 403 http://mydomain.com/sorry.gif
SetEnvIf Referer "^http://www\.pimprig\.com" good_referal
SetEnvIf Referer "^http://pimprig\.com" good_referal
SetEnvIf Referer "^http://forums\.pimprig\.com" good_referal
SetEnvIf Referer "^http://gallery\.pimprig\.com" good_referal
SetEnvIf Referer "^http://links\.pimprig\.com" good_referal
SetEnvIf Referer "^http://reviews\.pimprig\.com" good_referal
SetEnvIf Referer "^http://guides\.pimprig\.com" good_referal
SetEnvIf Referer "^http://systems\.pimprig\.com" good_referal
SetEnvIf Referer "^http://articles\.pimprig\.com" good_referal
SetEnvIf Referer "^http://news\.pimprig\.com" good_referal
SetEnvIf Referer "^http://team\.pimprig\.com" good_referal
SetEnvIf Referer "^$" good_referal

Order Deny,Allow
Deny from all
Allow from env=good_referal
</FilesMatch>

shiva
02-10-2005, 11:00 PM
Looks interesting, but a little confused. how would this affect the existing htaccess, could you just add this with the other code? Other question is I'm pretty new to this type of code, and I don't use subdomains, so would my code be instead of this:

SetEnvIf Referer "^http://forums\.pimprig\.com" good_referal

it would be this? :


SetEnvIf Referer "^http://www\.pimprig\.com\.forums" good_referal
SetEnvIf Referer "^http://pimprig\.com\.forums" good_referal

noppid
02-10-2005, 11:04 PM
Maybe just turn off attachments for guests?

Zachery
02-10-2005, 11:26 PM
Maybe just turn off attachments for guests?
Send them a HUGE 1600x1600 clear gif file (about 2.83k ;)) :)

noppid
02-11-2005, 12:05 AM
Send them a HUGE 1600x1600 clear gif file (about 2.83k ;)) :)

Very creative.

Zachery
02-11-2005, 12:24 AM
Very creative.
I can't be all good now can i >D

GlitterKill
02-11-2005, 02:29 PM
It should work fine with yoru other .htaccess code. Just add this at the bottom.

If you dont haev subdomains just delete the lines you dont need and change "pimprig" to your own subdomain. :)

T3MEDIA
02-11-2005, 03:58 PM
is this placed in the root or in the forum folder where the php files are? This is onething I was never sure on.

GlitterKill
02-12-2005, 11:35 AM
YOu can place it in the root web folder or the forums folder. :) Try it one way then test to make sure it's working. :)

clearchannel
02-25-2005, 10:43 PM
Would someone be so kind as to point out where I would place the code above. This is what my current htaccess looks like:

Options ExecCGI FollowSymLinks Includes
DirectoryIndex index.php index.htm index.html
AddHandler cgi-script .cgi
AddType application/x-httpd-cgi .cgi

<Limit GET>
order allow,deny
allow from all

deny from xxx.xxx.xx.x
deny from xxx.xxx.xx.xx

[/limit]

Thanks in advance.