.htaccess的访问/下载 [英] Htaccess access/download
问题描述
使用htaccess的我基本上是试图禁止访问该页面即 http://example.com ,但它仍将允许人们下载文件,如果他们有直接的联系,即 http://example.com/hi.zip一>
Using htaccess I'm basically trying to forbid access to the page i.e http://example.com, but it will still allow people to download files if they have a direct link i.e http://example.com/hi.zip.
我使用该目录指令的基本陈列下载页面。据此间 mod_autoindex.c 使用,所以基本上我想要做的是:
I'm using the directory directive to display the basic download page. According to here mod_autoindex.c is used,so basically what I'm trying to do is:
<Files mod_autoindex.c>
AuthType Basic
AuthName "Example"
AuthUserFile "/home/.htpasswd"
require valid-user
</Files>
任何意见/建议吗?
Any advice/tips?
推荐答案
这应该工作(在我的网络服务器进行测试:www.gopeter.de/test受到限制,www.gopeter.de/test/test.zip是允许的)
This should work (tested on my webserver: www.gopeter.de/test is restricted, www.gopeter.de/test/test.zip is allowed)
AuthType Basic
AuthName "Restricted Directory"
AuthUserFile /path/to/directory/.htpasswd
require valid-user
<FilesMatch "\.(gz|pdf|zip|rar)$" >
Order allow,deny
Allow from all
Satisfy any
</FilesMatch>
这篇关于.htaccess的访问/下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!