简体   繁体   中英

Apache Hotlink Protection for Download Folder

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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM