0
我有两个网址:http://...../m?PageView=View1&Language=English&AName=AAA和另一个http://...../m?PageView=View2TName=T1&AName=XYZ。这两个网址都是用于单独的部分/功能。但是因为参数的数量和模式是相同的,所以一个url工作而另一个不工作。类似网址的IIS管理器url规则
我想写两个类似url的url重定向和重写规则。我写了第一条规则如下。
<rule name="RedirectUserFriendlyURL12" stopProcessing="true">
<match url="^m/$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^View=([^=&]+)&Language=([^=&]+)&AName=([^=&]+)$" />
</conditions>
<action type="Redirect" url="m/{C:1}/{C:2}/{C:3}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL12" stopProcessing="true">
<match url="^m/([^/]+)/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="m?View={R:1}&Language={R:2}&AName={R:3}" />
</rule>
和另一个url具有相同数量的参数,但名称不同,如下所示。这是第二条规则。
<rule name="RedirectUserFriendlyURL12" stopProcessing="true">
<match url="^m/$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^View=([^=&]+)&TName=([^=&]+)&AName=([^=&]+)$" />
</conditions>
<action type="Redirect" url="m/{C:1}/{C:2}/{C:3}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL12" stopProcessing="true">
<match url="^m/([^/]+)/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="m?View={R:1}&TName={R:2}&AName={R:3}" />
</rule>
当我在web.config中有以上两条规则时,一个url可以正常工作,即重写和重写但是另一个不起作用。
如何区分这两个规则,以便它适用于这两个网址。
你能提供你想要的样品或重定向吗?这将有助于我理解你的规则,以及如何正确编写 –
修改过的问题在顶部。现在看看你是否可以帮忙.. – ghetal
你的重定向不工作?或重写不起作用?你的第二个'RewriteUserFriendlyURL12'将不起作用,因为它具有与第一次重写相同的'conditions'和'match url'。所有的请求将被重写'RewriteUserFriendlyURL12' –