Forum Moderators: goodroi

Message Too Old, No Replies

htaccess Allow robots.txt and leech protection

         

war59312

9:27 pm on Feb 22, 2006 (gmt 0)

10+ Year Member



Hello,

I am trying to setup my site so that people can not leech my files but still access error pages and so that robots can still access robots.txt .

The problem is that I'm still get 403 error when trying to access robots.txt.

I am currently using this:

#Stop Leechers For Hotlinking Images And Files
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(www.)?example.com(/)?.*$ [NC]
RewriteRule .*\.(torrent¦iso¦gif¦jpe?g¦avi¦css¦doc¦mid¦mov¦mp3¦mp4¦mpg¦pdf¦pps¦ppt¦ra¦ram¦swf¦wav¦wma¦xml¦png¦cab¦7z¦cmd¦txt¦log¦rar¦zip¦exe¦js¦ex_¦dll¦dl_¦inf¦in_¦sys¦sy_)$ - [F,NC]

#If the request is for robots.txt or any custom error page, by-pass mod_rewrite rules
RewriteRule ^(errors/[^/]+\.php¦robots\.txt)$ - [L]

So it seems the last rule does not work. :(

Thanks for any help,

Will

PS: Werid, I'm using code tags but not showing up in post but do in preview. I do NOT have the optioin to disable code tags in message either. Strange.

Mokita

9:54 pm on Feb 22, 2006 (gmt 0)

10+ Year Member


I use this code which works well:

#Disallow hotlinking while allowing from blank or localhost, requests for robots.txt and favicons
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(^/robots\.txt¦\.ico)$
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp¦pdf)$ [F,L]

NB: ensure you convert the broken pipes (¦) inserted by this forum, to solid pipes. Otherwise it won't work properly.

The forum also sometimes insists on removing the space between end curly bracket (}) and exclamation mark (!) - so ensure you add those in or you'll get a 500 server error.

war59312

3:30 am on Feb 23, 2006 (gmt 0)

10+ Year Member



Pefect, thanks a ton buddy,

Will :)