【问题标题】:Redirect to canonical URL is not working重定向到规范 URL 不起作用
【发布时间】:2012-06-05 14:12:40
【问题描述】:

我正在尝试为我的网站 (macton.com) 设置规范 URL,以便在开头添加 www。该网站使用 IIS 托管,我安装了 URL 重写器扩展。

这是我放在 web.config 文件中的代码。但是,它似乎什么也没做,因为它仍然是 macton.com。

<system.webServer>
    <rewrite>
        <rules>
            <rule name="Rewrite to www" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^macton\.com$" />
                </conditions>

                <action type="Redirect" redirectType="Permanent" url="http://www.macton.com/{R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

在此之后,我有一堆 带有可以正常工作的重定向标签。我尝试使用来自 macton.com → www.macton.com 的重定向,但这只会创建一个无限重定向循环(DUH!)

知道为什么这不起作用吗?我到处都说这是正确的代码!

【问题讨论】:

    标签: iis redirect url-rewriting web-config


    【解决方案1】:

    此链接可以帮助: http://www.awseibert.net/how-to/redirecting-canonical-names-in-iis-7

    您是否也将 macton.com 添加到您网站的绑定中?

    【讨论】:

      猜你喜欢
      • 2017-11-19
      • 2012-09-27
      • 2016-05-24
      • 2011-08-16
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      相关资源
      最近更新 更多