排除htaccess的保护目录的一个文件夹 [英] Exclude one folder in htaccess protected directory
问题描述
我得htaccess的保护目录。这里是code我现在用的:
I have a directory protected by htaccess. Here is the code I use now:
AuthName "Test Area"
Require valid-user
AuthUserFile "/***/.htpasswd"
AuthType basic
这是工作的罚款。不过,我现在有这个文件夹,我想允许任何人访问内部的目录,但我不知道该怎么做。
This is working fine. However, I now have a directory inside of this folder that I would like to allow anyone to access, but am not sure how to do it.
我知道这是可能的,只是将文件保护目录之外,而是要长话短说文件夹需要留在受保护的文件夹内,但要对所有人开放。
I know that it is possible to just move the files outside of the protected directory, but to make a long story short the folder needs to stay inside the protected folder, but be accessible to all.
我怎么能限制访问的文件夹,但允许访问的子文件夹?
How can I restrict access to the folder, but allow access to the subfolder?
推荐答案
据<一href="http://perishable$p$pss.com/$p$pss/2007/11/26/enable-file-or-directory-access-to-your-htaccess-password-protected-site/"相对=nofollow>这篇文章您可以通过使用 SetEnvIf之后
做到这一点。你每次你想要的文件夹和文件的匹配盛大的访问,并定义一个环境变量'允许'他们。然后添加一个条件,允许访问,如果这个环境变量present。
According to this article you can accomplish this by using SetEnvIf
. You match each of the folders and files you want to grand access to and define an environment variable 'allow' for them. Then you add a condition that allows access if this environment variable is present.
您需要将以下指令添加到您的.htaccess。
You need to add the following directives to your .htaccess.
SetEnvIf Request_URI "(path/to/directory/)$" allow
SetEnvIf Request_URI "(path/to/file\.php)$" allow
Order allow,deny
Allow from env=allow
Satisfy any
这篇关于排除htaccess的保护目录的一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!