将多个IIS7重写规则(重定向)合并为一个

GWR*_*GWR 4 iis-7 url-rewriting

我正在使用iis7的URL Rewrite模块来完成以下几件事:

  • 301重定向规则从非www到www
  • 301重定向规则.info到.com(移动到我的域的.com版本)
  • 301将规则从旧页面重定向,例如/page-name.asp到/ page-name

我已经能够将前两个合并为一个规则,第三个项目是它自己的规则.问题是在请求URL的情况下会生成两个301重定向:

site.info/page-name.asp/

首先执行301以执行以下操作:

www.site.com/page-name.asp(例如添加www,.info转到.com)

然后第二个301从那里完成:

www.site.com/page-name

我的问题是:我如何组合这些,以便只有一个301重定向而不是两个?以下是他们目前在我的web.config中的两条规则:

<rule name="SEO - 301 Redirect - .info to .com AND force WWW" stopProcessing="false">
    <match url="(.*)" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^site\.info$" />
    </conditions>
    <action type="Redirect" url="{ToLower:http://www.site.com/{R:1}}" redirectType="Permanent" />
</rule>
<rule name=".aspVersion-to-friendlyvia301" stopProcessing="false">
        <match url="(.*).asp" />
        <action type="Redirect" url="{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)

GWR*_*GWR 6

我似乎找到了自己问题的答案.这是一个黑客攻击,但完成所有必需的URL转换(例如尾随删除斜线,非www到www,toLowerCase,删除目录的默认文档,以及任何其他必要的重定向,如页面名称更改).

我所谈论的问题实际上被称为"301重定向链接",解决方案呈现得相当优雅,在这里:

http://www.seomoz.org/blog/what-every-seo-should-know-about-iis#chaining