在web.config中重定向

时间:2012-12-10 18:25:50

标签: iis redirect rewrite

有人可以告诉我为什么以下内容不能正确重写吗?

<rule name="Redirect account listing with levelId" stopProcessing="true">
<match url="^account/([^/]+)/([^/]+)/([^/]+)[?levelId=]$" />
<conditions>
  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="account/{R:1}/{R:2}/{R:3}" appendQueryString="false" />

我正在尝试重定向,以便删除“?levelId =。

1 个答案:

答案 0 :(得分:1)

我明白了......

<rule name="Redirect account listing with levelId b" stopProcessing="true">
<match url="^account/([^/]+)/([^/]+)/([^/]+)" />
<conditions>
  <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
  <add input="{QUERY_STRING}" pattern="^levelID=([^=&amp;]+)$" />
</conditions>
<action type="Redirect" url="account/{R:1}/{R:2}/{R:3}" appendQueryString="false" />