2017-05-31 167 views

回答

1

這條規則應該是所有您需要:

<rewrite> 
    <rules> 
     <rule name="root rule" stopProcessing="true"> 
      <match url="^$" /> 
      <action type="None" /> 
     </rule> 
     <rule name="redirect rule" stopProcessing="true"> 
      <match url="(.*)" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_URI}" pattern="^/css" negate="true" /> 
      <add input="{REQUEST_URI}" pattern="^/js" negate="true" /> 
      </conditions> 
      <action type="Redirect" url="/" /> 
     </rule> 
    </rules> 
</rewrite> 

第一個確保根不重定向到一個重定向循環,並停止處理,否則可能會申請更多的規則,和第二個排除您想要排除的文件夾,如果有更多的文件夾不需要重定向到根目錄,只需在條件中添加另一行。