我在 URL 重写方面真的很新,并试图重写/重定向多个查询,但似乎不起作用。由于这是搜索结果并且带有不同的过滤,因此查询可能会有所不同。例如,某些搜索我们可能有查询,t1=something
而在另一个我们可能有查询t2=somethingelse
,有时我们可能会像这样组合它们:t1=something&t2=somethingelse
我将 IIS7 与 web.config 一起使用,这是我到目前为止所做的:
这是我的示例链接
www.website.com/search/?t1=first&t2=second
我尝试了以下方法,但没有一个真正起作用:
(1)
<rewrite>
<rules>
<rule name="first" stopProcessing="true">
<match url="search/" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="t1=([0-9a-zA-Z]+)" />
</conditions>
<action type="Redirect" url="search/{C:1}/" appendQueryString="false" />
</rule>
<rule name="second" stopProcessing="true">
<match url="search/" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="t2=([0-9a-zA-Z]+)" />
</conditions>
<action type="Redirect" url="search/{C:1}/" appendQueryString="false" />
</rule>
</rules>
</rewrite>
(2)
<rule name="a" stopProcessing="true">
<match url="search2/" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="t1=([0-9a-zA-Z]+)" />
<add input="{QUERY_STRING}" pattern="t2=([0-9a-zA-Z]+)" />
</conditions>
<action type="Redirect" url="search2/{C:1}/{C:2}" appendQueryString="false" />
</rule>
我真的很感激任何帮助。
谢谢。