我有一个带有表单身份验证的 asp.net 网站,当页面超时时,它似乎遇到了重定向循环问题。
首先我的规则:
<rewrite>
<rules>
<clear />
<rule name="HTTP to HTTPS redirect" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Root to login page" enabled="true" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://{HTTP_HOST}/Account/Login.aspx" redirectType="Found" />
</rule>
<rule name="Login" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*/Login.aspx" />
<conditions>
<add input="{REQUEST_URI}" pattern="*account/login.aspx" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/Account/Login.aspx" />
</rule>
</rules>
</rewrite>
这里的意图是:
- 如果有人浏览到 http.//mysite.com,他们会被重定向到 https.//mysite.com
- 如果有人浏览到 https.//mysite.com/ 他们会被重定向到 https.//mysite.com/account/login.aspx
- 如果有人在我网站的任何文件夹或子文件夹中请求 login.aspx 页面,他们将被重定向到 https.//mysite.com/account/login.aspx
我已经确认关闭第一条规则后,当页面过期时,用户确实会被重定向到具有正确返回 URL 的登录页面(https.//mysite.com/account/login.aspx?ReturnUrl=%2fMemberPages%2fMyPage .aspx)。但是,当页面过期时打开第一个 urlrewrite 规则,用户得到一个页面无法显示的错误,地址栏中的 url 是 https.//mysite.com/memberpages/mypage.aspx。
我尝试调整各种设置,包括在ReturnUrl的第一条规则中添加排除项,但我无法让它发挥作用,而且我在截止日期前。谁能帮我一些建议?