我有以下重写规则
<rewrite>
<rules>
<rule name="1stLevelRule">
<match url="^([_0-9a-z-]+)" />
<action type="Rewrite" url="default.aspx?url={R:1}" />
</rule>
<rule name="2ndLevelRule">
<match url="^([0-9a-z-]+)/([0-9a-z-]+)" />
<action type="Rewrite" url="default.aspx?url={R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
然而由于某些原因它似乎正在改变页面上的所有图像和CSS,有其他人有同样的问题,任何人都可以告诉我如何阻止它这样做
谢谢
答案 0 :(得分:0)
问题是该文件的自身与第一条规则匹配,但图像js等与第二条规则匹配
修复很简单
<rewrite>
<rules>
<rule name="1stLevelRule" stopProcessing="true">
<match url="^([0-9a-z-]+)" />
<action type="Rewrite" url="default.aspx?url={R:1}" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
</rule>
<rule name="2ndLevelRule" stopProcessing="true">
<match url="^([0-9a-z-]+)/([0-9a-z-]+)" />
<action type="Rewrite" url="default.aspx?url={R:1}/{R:2}" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>