我需要创建一个 URL 重写规则,将 REMOTE_USER 值添加到查询字符串中。我将我的应用程序简化为绝对必需品。但是,在评估规则条件时,REMOTE_USER 始终为空。
我的网站在 IIS 7 中配置,应用程序池使用 .NET 2.0 的集成模式。我禁用了匿名身份验证并通过 IIS 管理器在站点上启用了 Windows 身份验证,我什至将这一行添加到 web.config 以防止匿名访问。这是我的两个文件。
网络配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authorization>
<remove users="?" roles="" verbs="" />
</authorization>
</security>
<rewrite>
<rules>
<clear />
<rule name="Add login into URL" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="login" negate="true" />
<add input="{REMOTE_USER}" pattern="(.*)" />
</conditions>
<action type="Redirect" url="{HTTP_URL}?login={C:1}" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
默认的.asp
<%= Request.ServerVariables("REMOTE_USER") %>
我的规则永远不会命中,因为在评估条件时 {REMOTE_USER} 总是空白(其他服务器变量显示在规则中,所以它只是 {REMOTE_USER})。不同之处在于 default.asp 显示了我的 REMOTE_USER 值。
任何建议为什么会发生这种情况?谢谢