If File exists, return file, If File does not exit, Rewrite
i need some help to write two URL rewrite rules in IIS7, i have tried for the last 3 hours with no success.
Basically, i have the following two rules:
<rule name="Resize Images - Game Thumbnails - Static" stopProcessing="true">
<match url="^images/c/games/(.+)x(.+)/(.+)$" />
<conditions logicalGrouping="MatchAny">
<add input="\mycms\games\images\thumbs\220x150\{R:3}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/mycms/games/images/thumbs/{R:1}x{R:2}/{R:3}" />
</rule>
<rule name="Resize Images - Game Thumbnails - Dynamic" stopProcessing="true">
<match url="^images/c/games/(.+)x(.+)/(.+)$" />
<conditions logicalGrouping="MatchAny开发者_StackOverflow社区">
<add input="\mycms\games\images\thumbs\{R:1}x{R:2}\{R:3}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/controls/makeThumb.aspx?folder=games&image={R:3}&w={R:1}&h={R:2}" />
</rule>
Both of the rules work if they are alone.
for example, if i put only the static rule, and the image exists, Then it returns the image.
if i leave only the dynamic rule, and the image does not exist, then it is created.
but why don't the rules work together?
Well i found the problem, basicly both of these rules work:
<rule name="Resize Images - Game Thumbnails - Static" stopProcessing="true">
<match url="^images/c/games/(.+)x(.+)/(.+)$" />
<conditions logicalGrouping="MatchAny">
<add input="{APPL_PHYSICAL_PATH}mycms\games\images\thumbs\{R:1}x{R:2}\{R:3}" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="/mycms/games/images/thumbs/{R:1}x{R:2}/{R:3}" />
</rule>
<rule name="Resize Images - Game Thumbnails - Dynamic" stopProcessing="true">
<match url="^images/c/games/(.+)x(.+)/(.+)$" />
<conditions logicalGrouping="MatchAny">
<add input="\mycms\games\images\thumbs\{R:1}x{R:2}\{R:3}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/controls/makeThumb.aspx?folder=games&image={R:3}&w={R:1}&h={R:2}" />
</rule>
BUT!!!! and this is a big but, if you delete the image ( for testing purposes or whatever ) the rule is somehow cached, and for some bizzare reason, the dynamic rule will not execute. the only way to force it to execute, is to recycle the application pool.
精彩评论