iis 将 https://example.com/default.aspx/default.aspx 的 url 重写为 https://example.com

iis rewrite url for https://example.com/default.aspx/default.aspx to https://example.com

我已经尝试了各种重写 URL,但无法让 IIS 发送 https://example.com/default.aspx/default.aspx to https://example.com/default.aspx

的 URL

Google 用错误的 URL 索引了站点,而 Bing 却正确(看图)。任何帮助将非常感激。我所有的流量都错了 url (https://example.com/default.aspx/default.aspx).

<rewrite>
  <rules>
    <rule name="Redirect www.xxx.com to xxx.com" patternSyntax="ECMAScript" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^https://example.com/default.aspx/default.aspx" />
      </conditions>
      <action type="Redirect" url="default.aspx" />
    </rule>

    <rule name="redirect two character to default" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{URL}" pattern="^/[a-z]{2}(/)?$" />
      </conditions>
      <action type="Redirect" url="default.aspx" appendQueryString="false" />
    </rule>
  </rules>
</rewrite>

您的规则存在一些问题。 {HTTP_HOST} 只匹配 www.example.com 的主机名,不会匹配整个 URL.

您可以尝试以下规则:

<rule name="Redirect www.xxx.com to xxx.com" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
  <match url=".*" />
  <conditions>
                    <add input="{HTTP_HOST}" pattern="www.example.com" />
                    <add input="{HTTPS}" pattern="on" />
                    <add input="{REQUEST_URI}" pattern="default/default|default.aspx/default.aspx" />
  </conditions>
  <action type="Redirect" url="default.aspx" />
</rule>