网站正在重定向到 www.www.sitename.com

Site getting redirect to www.www.sitename.com

我的网站重定向到 www.www.sitename.com 时遇到了这个问题。

我用 web.config 编写了这段代码,它适用于我的其他网站。

<system.webServer>
    <rewrite>
      <rules>

        <clear />
        <rule name="Redirect to WWW" enabled="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" />
          </conditions>
          <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>

      </rules>
    </rewrite>
  </system.webServer>

这是其他网站 100% 工作的代码,但在本网站上有 www.www.sitename.com 问题 srilanka-tours.co

如何减少通用性,更专注于您的实际主机名?

例如:

<rule name="Redirect to WWW">
    <match url="(.*)" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^www\.srilanka-tours\.co$" negate="true" />
        </conditions>
        <action type="Redirect" 
                url="http://www.srilanka-tours.co/{R:1}" 
                redirectType="Permanent" />
</rule>

(这是现实世界重写规则的摘录)。

以上规则类似于您在 IIS 管理器的 "wizard" 中使用 "Canonical Domain Name" 创建重写规则时得到的规则。 See the article on Scott Guthrie's blog.