Apache Hotlink Protection for Download Folder

眉间皱痕 提交于 2019-12-19 04:45:50

问题


I'm trying to avoid direct links from other sites to my site's downloadables.

My exe,zip and msi files are under /files directory. How can I avoid direct links to them?

Thanks in advance...


回答1:


Add the following to a .htaccess file in your /files directory

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(exe|zip|msi)$ /images/nohotlink.jpg [L]

Change "mysite.com" to your domain and /images/nohotlink.jpg to an image you wish to display telling users hotlinking is not allowed.

For more detailed information check out:

http://altlab.com/htaccess_tutorial.html



来源:https://stackoverflow.com/questions/1775582/apache-hotlink-protection-for-download-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!