【发布时间】:2019-11-11 16:27:51
【问题描述】:
我正在尝试使用 IIS 7 中的 URL 规则引擎将我们当前的产品页面重定向到我们的新产品页面。
旧页面:
example.com/itemform.aspx?item=X12878
example.com/itemform.aspx?item=Y87304&showmenu=T
新网址
example.com/c/product/X12878
example.com/c/product/Y87304
尝试
<rule name="Product Page Redirect">
<match url="/itemform\.aspx\?item=([.a-zA-Z0-9]+)$" />
<action type="Redirect" url="https://newsite.com/x/product/{C:1}" redirectType="Permanent" />
</rule>
根据 Emma 的建议完成重写规则
<rewrite>
<rules>
<rule name="Product Page Redirect" stopProcessing="true">
<match url="/itemform\.aspx\?item=([A-Za-z0-9.]+)" />
<conditions>
</conditions>
<action type="Redirect" url="https://newsite.com/x/product/{R:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
【问题讨论】: