Apache Trouble
blimp
Join Date: 2003-03-12 Member: 14438Members, Constellation
<div class="IPBDescription">.. blocking certain referers</div> Okay. I'm a mirror. I don't mind people downloading and using all my bandwith. What I do mind, is a certain french site using me as their main mirror and taking credit for it.
Therefore, I've been trying to block downloads when their site is the referrer. No such luck.
I ask for help to fix this, as I find it wrong for certain people to just rip me off like this.
############
I'm using .htaccess to fix this problem.
.htaccess in the folder where the files are (This one accepts specific domains)
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://panama.mine.nu/~files/ns/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.kfs-gaming.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://natural-selection.org/downloads.html.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.natural-selection.org/downloads.html.*$ [NC]
RewriteRule .*$ http://kfs-gaming.com/images/squad/make.jpg<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
This one should allow people panama.mine.nu, kfs-gaming.com and natural-selection.org. What happens is that everyone gets blocked (403).
So. Lets try a new approach! (Blocking specific domains)
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Rewriteengine on
RewriteCond %{HTTP_REFERER} ^http://www.removed-domain-for-flaming.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.removed-domain-for-flaming.nu/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.openlan.net/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://wwwstud.hint.no/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|exe|EXE)$ http://www.kfs-gaming.com/?go=download [R]<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
The domains that are in the list are for testing (obviously, the two first, are not). Same thing happens here; everyone gets blocked (403).
All files in the folder are chmodded to 755.
My <a href='http://panama.mine.nu/httpd.conf' target='_blank'>httpd.conf</a>
Therefore, I've been trying to block downloads when their site is the referrer. No such luck.
I ask for help to fix this, as I find it wrong for certain people to just rip me off like this.
############
I'm using .htaccess to fix this problem.
.htaccess in the folder where the files are (This one accepts specific domains)
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://panama.mine.nu/~files/ns/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.kfs-gaming.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://natural-selection.org/downloads.html.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.natural-selection.org/downloads.html.*$ [NC]
RewriteRule .*$ http://kfs-gaming.com/images/squad/make.jpg<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
This one should allow people panama.mine.nu, kfs-gaming.com and natural-selection.org. What happens is that everyone gets blocked (403).
So. Lets try a new approach! (Blocking specific domains)
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Rewriteengine on
RewriteCond %{HTTP_REFERER} ^http://www.removed-domain-for-flaming.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.removed-domain-for-flaming.nu/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.openlan.net/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://wwwstud.hint.no/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|exe|EXE)$ http://www.kfs-gaming.com/?go=download [R]<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
The domains that are in the list are for testing (obviously, the two first, are not). Same thing happens here; everyone gets blocked (403).
All files in the folder are chmodded to 755.
My <a href='http://panama.mine.nu/httpd.conf' target='_blank'>httpd.conf</a>
Comments
CRAZY BUMP
/me runs
<a href='http://www.freewebmasterhelp.com/tutorials/htaccess/1' target='_blank'>http://www.freewebmasterhelp.com/tutorials/htaccess/1</a>
<a href='http://www.javascriptkit.com/howto/htaccess.shtml' target='_blank'>http://www.javascriptkit.com/howto/htaccess.shtml</a>
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->RewriteEngine on
RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^http://(.*)natural-selection\.org/.*$ [NC]
RewriteRule .*\.([gif|jpe?g]+)$ - [NC,F]<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
Simply set up a .htaccess within the relevant directory and configure the access controls as per the guides set out in the manual:
<a href='http://httpd.apache.org/docs-2.0/howto/auth.html' target='_blank'>http://httpd.apache.org/docs-2.0/howto/auth.html</a>
The rewrites you have shown are also valid but a lot more complex to implement.
In my book always choose the path of least resistance i.e. the easy option. Just block the hosts directly using access controls.
Regards
Haven
It looks to me I can only deny specific hosts, and I'm not able to block every person downloading via. another site.
Don't worry Haven, we're only human.
If anyone feels like checking my httpd.conf for errors I'd be happy, I'm pretty sure thats where the problem is, since my syntax is correct and all.