Forum Moderators: phranque
SetEnvIfNoCase Referer ^http://(<^/>*\.)?www.domain\.tld access_is_ok
SetEnvIfNoCase Referer ^http://(<^/>*\.)?domain\.tld access_is_ok
Order deny,allow
Deny from all
Allow from env=access_is_ok
so ... direct linking and leeching from other sites is not possible anymore... but ...i get email from lots of peoples now telling me that they cant download from my site anymore when a download manager is used.
i thought about setting up a cookie valid for like 30 minutes when you enter my site and .htaccess checks if the cookie exists and is valid when you want to download a file ... but i dont know if that is possible with .htaccess nor how such a file would look like :(
btw. as download system i use Powerdownload 2.2.4
id be glad if someone can help me out with a better solution then mine asap ...
thnx in advance
DJ-Ready
Welcome to WebmasterWorld [webmasterworld.com]!
You need to consider either enabling blank referrers, or allowing access by User-Agent.
Look at your raw server logs for downloads that failed, and see which user-agents appear to be the problem.
Jim
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://domain.tld/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.domain.tld/.*$ [NC]
RewriteRule .*\.(exe¦rar¦zip¦mp3¦avi)$ [domain.tld...] [R,NC]
im starting to get mad on this .. aaw
The thing is, protecting your files efficiently is quite hard, but at least it is possible. You can't expect to be able to copy and paste a solution that worked elsewhere and expect it to work for you.
There is no alternative to actually learning what the various components of a .htaccess file (the rewrite conditions, the rewrite rules, the "regular expressions" etc) do and writing your own to do just what you want them to do. It's a tricky but worthwhile project and there are a lot of tips and examples in this forum.
I can give you examples of allowing blank referrers and allowing certain user-agents regardless of referrer, but what I cannot do is to tell you which is more appropriate for your situation. Again, there is no one-size-fits-all solution.
Allow blank referrers:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain\.com [NC]
RewriteRule \.(exe¦rar¦zip¦mp3¦avi)$ - [F]
Allow certain downloaders:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^Wget
RewriteCond %{HTTP_USER_AGENT} !^RealDownload
RewriteCond %{HTTP_USER_AGENT} !^SmartDownload
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain\.com [NC]
RewriteRule \.(exe¦rar¦zip¦mp3¦avi)$ - [F]
Only you can make the trade-offs between the various approaches of open access, allowing blank referrers, or allowing only certain downloaders if the referrer address is missing or incorrect.
This Introduction to mod_rewrite [webmasterworld.com] thread is a good start, and contains vital links to tutorials and documentation that you will need to read in order to get comfortable with regular expressions mod_access, and mod_rewrite.
You will need to replace all broken pipe "¦" characters in the code above with the solid pipe from your keyboard.
Jim