如何从子目录中删除.htaccess密码保护

jus*_*inl 92 .htaccess password-protection subdirectory

我有密码保护我的整个网站使用,.htaccess但我想公开其中一个子目录,以便无需密码即可查看.

如何禁用子目录的htaccess密码保护?具体是什么.htaccess语法.

这是我的.htaccess文件放在我的ftp的根目录中.

AuthName "Site Administratrion"
AuthUserFile /dir/.htpasswd
AuthGroupFile /dev/null

AuthName secure
AuthType Basic
require user username1
order allow,deny
allow from all

Rag*_*geZ 146

您需要.htaccess在所需目录中创建一个新文件,并Satisfy any在其中包含该指令,对于Apache 2.3:

# allows any user to see this directory
Satisfy Any
Run Code Online (Sandbox Code Playgroud)

在Apache 2.4中更改了语法,这具有相同的效果:

Require all granted
Run Code Online (Sandbox Code Playgroud)

  • 它对我也不起作用.我不能得到满足. (12认同)
  • 我只能用"允许所有人"而不是"满足任何人"来使用它. (7认同)
  • @dave我更新了答案,以防你使用apache 2.4 (3认同)
  • @JessTelford"Satisfy Any"正在发挥作用,它被拼错为"Satisify Any".可能这就是它不适合你的原因. (2认同)

ato*_*nyc 34

添加到RageZ的答案,我在服务器指令中使用了这个:

<Directory /var/www/protected/>
     AuthType Basic
     AuthName "Production"
     AuthUserFile /path/to/.htpasswd
     Require valid-user
</Directory>

<Directory /var/www/protected/unprotected>
     Satisfy Any
</Directory>
Run Code Online (Sandbox Code Playgroud)

真棒.谢谢RageZ!


Pau*_*Rad 8

只需.htaccess使用以下指令在所需的子目录中创建一个新的:

Allow from all

您只能使用以下内容限制您的IP:

Allow from x.x.x.x

请参阅:http://httpd.apache.org/docs/current/mod/mod_access_compat.html