【问题标题】:Canonical Rewrite for subpages not working by using rewrite rules in web.config使用 web.config 中的重写规则对子页面不起作用的规范重写
【发布时间】:2013-04-17 13:55:39
【问题描述】:

我们在 Azure 上托管了一个简单的 HTML asp.net 网站,当我们在浏览器中复制粘贴子页面 URL(没有 WWW)时,我们面临重定向问题。 示例:www.example.com/subpage.aspx 工作正常,但在复制粘贴 example.com/subpage.aspx 时,它会重定向到 www.example.comsubpage.aspx/(坦率地说,不知道发生在哪里以及如何发生)

以下代码是实时写在web.config文件中的,(具体域名除外)

<rewrite>
        <rules>
          <rule name="RedirectToWWW" stopProcessing="false">
                <match url=".*" />
               <conditions>
                    <add input="{HTTP_HOST}" pattern="^example\.com$" />
                </conditions>
                 <action type="Redirect" url="http://www.example.com/{R:0}" />
            </rule>
        </rules>
     </rewrite>

我是这个项目的新手,所以关于我应该从哪里开始调查或应该在哪里进行修复的任何指导都会非常有帮助。

【问题讨论】:

  • <rewrite><rules><rule name="RedirectToWWW" stopprocessing="false"><match url=".*"></match><conditions><add input="{HTTP_HOST }" pattern="^eyeswidewhat\.net$"></add></conditions><action type="Redirect" url="&lt;a href=" http: rel="nofollow" target="_blank">eyeswidewhat.net{R:0}" /&gt; </action></rule></rules></rewrite>

标签: .net azure iis-7 rewrite canonical-link


【解决方案1】:

改为:

<action type="Redirect" url="http://www.eyeswidewhat.net/{R:1}" />

另外,将stopProccessing 设置为true

【讨论】:

    猜你喜欢
    • 2015-07-10
    • 2012-08-05
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    相关资源
    最近更新 更多