为什么美元符号在URL重写不起作用?
问题描述:
望着问题How do I use web.config to redirect to a query string on Windows Server 2008 R2?为什么美元符号在URL重写不起作用?
这是我在web.config中:
<rule name="Rewrite Rule 21" stopProcessing="true">
<match url="^page/$1-per-year$" />
<action type="Redirect" url="/1-dollar-per-year" redirectType="Permanent" />
</rule>
我每次得到一个404错误。即使试过%24
我该如何得到这个工作?我所有的其他重定向都工作正常。
答
在你的正则表达式中,你只需要摆脱美元符号(\ $)。你的规则应该是:
<rule name="Rewrite Rule 21" stopProcessing="true">
<match url="^page/\$1-per-year$" />
<action type="Redirect" url="/1-dollar-per-year" redirectType="Permanent" />
</rule>