【发布时间】:2012-03-02 14:13:43
【问题描述】:
第一个重写规则(如下),“重写为可读 URL”,完美运行。第二条规则“删除 WWW 前缀”从 URL 中删除 WWW 前缀,因此:
http://www.mydomain.com/blog...
变成这样:
http://mydomain.com/blob...
现在这造成了一些破坏。虽然文章加载正常,但如果规则必须起作用,例如存在 WWW,浏览器地址栏中的 URL 不幸地变回不可读的版本,如下所示:
http://mydomain.com/blog/article.asp?id=1&title=blog-title
但重写已经成功,WWW 已被删除。但是为什么它从友好的 URL 变成了非友好的 URL?谁能发现我的错误或建议如何纠正这个错误?
这是我的 web.config 文件的一部分:
<rules>
<rule name="Rewrite to readable URL">
<match url="^blog/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="blog/article.asp?id={R:1}&title={R:2}" />
</rule>
<rule name="Remove WWW prefix" >
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mydomain\.com" />
</conditions>
<action type="Redirect" url="https://mydomain.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
【问题讨论】:
标签: url-rewriting friendly-url seo