2014-10-06 66 views
0

如何使用IIS重寫來重寫網站的基本路徑(即/)?如何用IIS重寫來重寫基路徑(即「/」)?

我已經試過這至今:

<rule name="RewriteIndexUrl" 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" /> 
</rule> 

目前,它不是重複編寫基本路徑,並且它直接返回index.html

回答

0

我能想出一個可行的解決方案,它的工作:

  1. 刪除在IIS站點的所有默認文檔(即index.htmlindex.htmdefault.aspx ...)

  2. 添加以下重寫規則:

<rule name="RewriteIndexUrl" stopProcessing="true"> 
    <match url="^" /> 
    <conditions> 
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="false" /> 
    </conditions> 
    <action type="Rewrite" url="index.html" /> 
</rule>