对仅影响移动设备的重定向循环进行故障排除

问题描述

我正在使用IIS10和URL-Rewrite,由于某种原因,我的网站具有重定向循环,但仅在移动设备上。无论是哪个移动设备,连接的网络或清除缓存的次数,该站点都不会在任何移动设备的任何浏览器上加载。我已经使用iphone,android,chrome,firefox和safari进行了测试。

这是我在web.config中的规则

<rewrite>
      <rules>
        <rule name="CanonicalHostNameRule1">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
            <add input="{HTTP_HOST}" pattern="^(.*)\.example\.com$" negate="true" />
          </conditions>
          <action type="Redirect" url="http://example.com/{R:1}" />
        </rule>
        <rule name="Redirect to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
        </rule>
      </rules>
    </rewrite>

我在同一台计算机上托管了其他具有相同URL重写规则的网站,这些网站正常工作没有问题。

即使我的所有规则都已关闭,我仍然在移动设备上遇到重定向循环。

任何有关如何解决此问题的工具,提示/技巧都将不胜感激!


更新:来自fiddler的信息

RAW:

HTTP/1.1 301 Moved Permanently
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: http://example.com/
X-Redirect-Reason: Wrong Portal Alias Requested
Set-Cookie: dnn_IsMobile=True; path=/; HttpOnly
Set-Cookie: language=en-US; path=/; HttpOnly
X-XSS-Protection: 1; mode=block
x-frame-options: SAMEORIGIN
Date: Thu,29 Oct 2020 13:19:56 GMT
Content-Length: 142

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://example.com/">here</a>.</h2>
</body></html>

标题

**Response Headers**
HTTP/1.1 301 Moved Permanently
**Cache**
Cache-Control: private
Date: Thu,29 Oct 2020 13:19:56 GMT
**Cookies/Login**
Set-Cookie: dnn_IsMobile=True; path=/; HttpOnly
Set-Cookie: language=en-US; path=/; HttpOnly
**Entity**
Content-Length: 142
Content-Type: text/html; charset=utf-8
**Miscellaneous**
X-Redirect-Reason: Wrong Portal Alias Requested
**Security**
x-frame-options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
**Transport**
Location: http://example.com/

我看到了Wrong Portal Alias Requested,但不确定是什么原因造成的?

解决方法

感谢LexLi,他使我朝着正确的方向看。提琴手非常有帮助。

是的,该网站是在DNN CMS应用程序上构建的,问题是在DNN中有一个表portalsettings的表名为DefaultPortalAlias的设置,在此设置中有错误的值。 / p>

在DNN的PortalAlias表中,还有bit的{​​{1}}字段,在我的情况下,IsPrimary设置为别名的IsPrimary版本而不是www.,在IIS中,我的url重写规范规则指向non-www.绑定,这是导致循环的原因。我不确定为什么它只影响移动设备,但在这些更改后现在可以正常工作。

感谢@Lex Li的见解!

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...