【发布时间】:2015-10-13 20:53:49
【问题描述】:
我有一个带有/contact.aspx 的网站,它成功重定向到/contact
但我想将我的旧/content.aspx?contentid=123 重定向到/about/123
这是我的 web.config 中的重定向 XML 部分:
<rewrite>
<rules>
<rule name="contact" patternSyntax="Wildcard" stopProcessing="true">
<match url="contact.aspx" />
<action type="Redirect" url="Contact" redirectType="Found" />
</rule>
<rule name="Content" patternSyntax="Wildcard" stopProcessing="true">
<match url="content.aspx?contentID=*" />
<action type="Redirect" url="About/{R:1}" appendQueryString="false" redirectType="Found" />
</rule>
</rules>
</rewrite>
访问 mydomain.com/content.aspx?contentid=123 给我一个 404。
也试过没有appendQueryString="false"
对我来说似乎很容易解决,但我错过了一些东西......
使用正则表达式而不是通配符也会给出 404:
<rule name="Content">
<match url="content.aspx?contentID=([0-9]+)" />
<action type="Redirect" url="About/{R:1}" redirectType="Found" />
</rule>
【问题讨论】:
标签: asp.net-mvc url-rewriting iis-7 url-rewrite-module