开发者

Problem with similar rules IIS 7 Rewrite

开发者 https://www.devze.com 2023-01-08 14:52 出处:网络
I have 2 similar rewrite rules, that 开发者_Python百科is killing each other. These are my rules: <rule name=\"Product rewrite\">

I have 2 similar rewrite rules, that 开发者_Python百科is killing each other.

These are my rules:

<rule name="Product rewrite">
<match url="^product/([_0-9a-z-]+)/([0-9]+)" />
<action type="Rewrite" url="product.asp?id={R:2}" />
</rule>

<rule name="Article rewrite">
<match url="^([_0-9a-z-]+)/([0-9]+)" />
<action type="Rewrite" url="article.asp?id={R:2}" />
</rule>

Now the problem is that when I call page like this:

/product/56-little-stars/14

then page article.asp is called, instead product.asp, but when I set URL like this:

/product/56-little-stars/14

then everything is all right. So can you tell me how to make that all 2 rewrite rules works together. I want be able to call article like this:

/this-is-title-of-my-article/11 <-> article.asp?id=11

And to call product like this

/product/56-little-stars/14 <-> product.asp?id=14

Thank you !


If I understand correctly you just need to add the stopProcessing="true" so that once the product rule applies (which is the more specific) then it will not apply the second one.

<rule name="Product rewrite" stopProcessing="true">  
0

精彩评论

暂无评论...
验证码 换一张
取 消