2011-10-02 39 views
6

我的urlrewrites出現問題 - 任何時候我指向要重寫的頁面,因爲它也將規則應用於css & js文件在我的網頁中引用。IIS網址重寫-css和js被錯誤地重寫

要嘗試和補救這一點,我把一個完全合格的路徑到CSS和JS - 這使得罰款的任何頁面的重寫不適用,但當我嘗試訪問重寫頁面瀏覽器掛起。

有沒有人遇到類似的東西,如果有的話,你有一個解決方案?感謝任何幫助。嘗試在類似的問題上查看網站,但目前爲止沒有任何幫助。

<rewrite> 
<outboundRules> 
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1" stopProcessing="true"> 
<match filterByTags="A, Form, Img" pattern="^(.*/)myapplicationname/Index\.html\?team=([^=&amp;]+)$" /> 
<action type="Rewrite" value="{R:1}team/{R:2}/" /> 
</rule> 
<preConditions> 
<preCondition name="ResponseIsHtml1"> 
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
</preCondition> 
</preConditions> 
</outboundRules> 
<rules> 
<rule name="RedirectUserFriendlyURL1" stopProcessing="true"> 
<match url="^myapplicationname/Index\.html$" /> 
<conditions> 
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> 
<add input="{QUERY_STRING}" pattern="^([^=&amp;]+)=([^=&amp;]+)$" /> 
</conditions> 
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" /> 
</rule> 
<rule name="RewriteUserFriendlyURL1" stopProcessing="true"> 
<match url="^([^/]+)/([^/]+)/?$" /> 
<conditions> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
</conditions> 
<action type="Rewrite" url="Index.html?{R:1}={R:2}" appendQueryString="false" /> 
</rule> 
</rules> 
</rewrite> 

我的網頁中:

<script src="/myapplicationname/Scripts/jquery-1.4.1.js" type="text/javascript"> </script> 
<link href="/myapplicationname/Styles/MainStyle.css" rel="stylesheet" type="text/css" /> 

正在申請重寫這些,並試圖找到/myapplicationname/Team/Styles/MainStyle.css並與JS文件類似。

回答

4

嘗試通過逐個刪除問題來找出導致問題的規則。現在添加一個條件到規則:

<rule name="Some rule"> 
     ... 
     <conditions logicalGrouping="MatchAny"> 
      <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v)$" negate="true" /> 
     </conditions> 
    </rule> 

這將避免運行與.js文件,結束的CSS文件的規則等