gpt4 book ai didi

apache - 密码保护虚拟目录? - .htpasswd/.htaccess

转载 作者:行者123 更新时间:2023-12-04 17:01:03 25 4
gpt4 key购买 nike

是否可以密码保护虚拟目录(例如 wordpress 类别):

/c/sofas/

它看起来像 <Location /c/sofas/>可以在 httpd_config 中工作,但不能在 .htaccess 中使用

是否可以?可能在某处使用 mod_rewrite 吗?

最佳答案

不幸的是<Location> .htaccess 中不允许使用指令.

但是有一个替代的简洁解决方案使用 mod_setenvif .

# set env variable SECURED if current URI is /c/sofas/
SetEnvIfNoCase Request_URI "^/c/sofas/" SECURED

# invoke basic auth is SECURED is set
AuthType Basic
AuthName "My Protected Area"
AuthUserFile /full/path/to/passwords
Require valid-user
Satisfy any
Order allow,deny
Allow from all
Deny from env=SECURED

关于apache - 密码保护虚拟目录? - .htpasswd/.htaccess,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19328665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com