IIS URL 重写无法通过搜索引擎运行

IIS URL rewrite not working via search engines

我已经为我在 IIS 10 中托管的网站编写了一个简单的 url 重写规则。它运行完美,没有任何问题。

但是,有一个奇怪的行为。当我直接在浏览器规则中写 url 时,规则工作正常,但是如果我在 Google/Bing 中搜索 url 然后点击搜索页面上的 url,规则没有触发。

我查看了 Insights 没有找到任何相关信息。

这是规则 -

<rule name="PROD Rule" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^myweb\.com$" />
      </conditions>
      <action type="Redirect" url="https://www.mywebsite.com/{R:0}" redirectType="Permanent" />
</rule>

直接在浏览器中写入url -

myweb.com 重定向到 https://www.mywebsite.com/

正在搜索引擎 Google/Bing 中搜索 url,然后在搜索结果页面上单击 url -

myweb.com 停留在 myweb.com

我原以为只要请求到达 IIS,无论来源如何,规则都应该触发。

您可以使用下面的 url 重写规则:

<rule name="Force SSL" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
            </rule>

原来不是搜索引擎的问题。相反,这只是我编写的重写规则遗漏的案例。

现有规则期望 myweb.com 作为输入并正确地将它们重定向到 https://www.mywebsite.com/

但是,当我在搜索引擎上搜索相同的 url 并点击它们时。 Url 发送到服务器不是 myweb.com 而是 www.myweb.com

这是一个有效的更新规则 -

<rule name="PROD Rule" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="^myweb\.com$" />
        <add input="{HTTP_HOST}" pattern="^threeinsure\.com$" />
    </conditions>
    <action type="Redirect" url="https://www.mywebsite.com/{R:0}" redirectType="Permanent" />
</rule>