【发布时间】:2017-05-29 03:10:01
【问题描述】:
我想限制对特定路径使用 HTTP Basic Auth 的访问,以便访问 /www/private 的人会收到身份验证提示,但不会提示 /www/public 、 /www/public/dashboard ....
注意:“private”、“public”、“dashboard”等不是文件夹,而是url重写
我当前的网络配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$" ignoreCase="false" negate="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
<location path="mysite/www/private">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<basicAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
<location path="mysite/www">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<basicAuthentication enabled="false" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
但这不起作用 - 它从不提示授权
【问题讨论】:
-
不太明白" 注意:"private"、"public"、"dashboard" 等不是文件夹,而是 url rewrite"。我没有看到任何重写为 private 的重写规则。你能提供你正在使用的网址吗?
-
我正在使用 nette 框架来处理这个问题。对不起,我不知道具体情况。但关键是这些网址不是文件夹。