2012-03-08 133 views
1

我有一個規則設置重寫一切進入一個子目錄,如下所示:重寫規則,以所有重寫除非文件擴展名

<rule name="Forms Directory" stopProcessing="true"> 
    <match url="^forms/(.*)" /> 
    <action type="Redirect" url="forms.htm" redirectType="Permanent" /> 
</rule> 

不過,我想稍作改變,以允許它訪問在表格的文件夾ASP文件。所以我要保持相同的規則,但符合規則排除任何的.asp。我嘗試以下,但不能把它按預期工作:

<rule name="Forms Directory" stopProcessing="true"> 
    <match url="^forms/(.*)[^(.asp)]" /> 
    <action type="Redirect" url="forms.htm" redirectType="Permanent" /> 
</rule> 

任何幫助將不勝感激!

回答

1

,檢查的文件擴展名的附加條件解決這個問題。

<rule name="Forms Directory"> 
    <match url="^forms/(.*)" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" pattern=".+\.asp$" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="forms.htm" redirectType="Permanent" /> 
</rule>