【发布时间】:2014-07-23 20:26:51
【问题描述】:
出于 SEO 优化的原因,我将所有对 http://Example.com 的请求重定向到 http://www.Example.com。问题是在本地工作时,对localhost 的请求也会被重定向。
我尝试了这个Rewrite rule to HTTPS except when on localhost 答案中的建议,但没有成功。
这是我位于Web.Config 的实际重定向规则(希望它可以帮助正在寻找重写规则到 WWW 的人):
<system.webServer>
<rewrite>
<rules>
<rule name="redirect example.com to www.example.com">
<match url="^(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
有什么帮助吗?
【问题讨论】:
标签: asp.net url-rewriting web-config