Apache htaccess限制身份验证,但文件上出现异常
我看过其他一些相关的帖子,但没有找到任何解决方案 我需要限制具有身份验证的文件夹,它可以工作。 但在这个文件夹中,我需要向每个人打开一个文件访问权限,我使用了这个,但它不起作用:Apache htaccess限制身份验证,但文件上出现异常,apache,.htaccess,.htpasswd,Apache,.htaccess,.htpasswd,我看过其他一些相关的帖子,但没有找到任何解决方案 我需要限制具有身份验证的文件夹,它可以工作。 但在这个文件夹中,我需要向每个人打开一个文件访问权限,我使用了这个,但它不起作用: AuthName "Admins Only" AuthUserFile /home/dd/.htpasswd AuthGroupFile /dev/null AuthType basic require user AuthorizedUser Options -Indexes <Files "admin-ajax
AuthName "Admins Only"
AuthUserFile /home/dd/.htpasswd
AuthGroupFile /dev/null
AuthType basic
require user AuthorizedUser
Options -Indexes
<Files "admin-ajax.php">
Allow from all
Satisfy all
</Files>
AuthName“仅限管理员”
AuthUserFile/home/dd/.htpasswd
AuthGroupFile/dev/null
AuthType basic
需要用户授权者
选项-索引
通融
满足所有
对不起,我的英语不好,谢谢你的帮助 使用SetEnv和Order指令:
#set variable if uri is "/admin-ajax.php"
SetEnvIf Request_URI ^/folder/admin-ajax\.php noauth=1
#auth
AuthName "Admins Only"
AuthUserFile /home/dd/.htpasswd
AuthGroupFile /dev/null
AuthType basic
require user AuthorizedUser
#Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require user AuthorizedUser
Allow from env=noauth
这将允许您在不登录服务器的情况下访问管理员ajax.php。很抱歉,它不起作用。如果我试图访问此文件,我仍然会显示登录窗口。我应该使用完整的serveur url:
setenif Request\u URI^/home/dd/admin ajax\.php noauth=1
?admin ajax.php的完整url是什么?你的admin-ajax.php文件在根文件夹中吗?admin-ajax.php文件位于子文件夹中,而不是根文件夹中:/home/www/folder/admin ajax.php
。网站的根文件夹是/home/www/
。我更新了主帖子中的url,使其更易于理解^^。我编辑了我的答案,在setenif行中将文件夹替换为子文件夹的名称