2013-06-20 58 views
4

使用以下规则,我可以成功重写url以重定向到app/index.cshtml。如图像,CSS和JavaScript的索姆资源不应该被重定向,所以我使用条件:IIS Url Rewrite:如何忽略缩小的javascript和css

<rule name="AngularJS"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     <add input="{URL}" negate="true" pattern="\.png$" /> 
     <add input="{URL}" negate="true" pattern="\.css$" />> 
     <add input="{URL}" negate="true" pattern="\.js$" /> 
     </conditions> 
     <action type="Rewrite" url="app/index.cshtml" /> 
    </rule> 

但只要我开始使用缩小的内容,请求的URL变成类似于:

/MYAPP/bundles/utilities?v = EH9YuZDBt_fj7iqRP2QA8lCkJ59wjV6woELIwvR7irk1

如何防止该类型的URL重定向?

+1

可能重复[IIS重写URL](http://stackoverflow.com/questions/17195698/iis-rewriting-url) – cheesemacfly

回答

5

您可以创建忽略规则,匹配忽略的网址的

<rule name="Ignore" enabled="true" stopProcessing="true"> 
    <match url="^(images|css|bundles).*"/> 
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false"/> 
    <action type="None"/> 
</rule> 
+1

大!谢谢你的帮助 :) – Sam