2016-03-28 57 views
0

我想在iis瀏覽過程中刪除.html extensnion當我瀏覽本地主機,應該顯示索引或默認的HTML不顯示,當我瀏覽文件夾中的任何文件與extension.html作爲o說HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.認爲文件存在。IIS刪除.html擴展名不工作文件夾文件瀏覽

我的web.config

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
<defaultDocument> 
<files> 
<clear /> 
<add value="index.html" /> 
<add value="Default.htm" /> 
<add value="Default.asp" /> 
<add value="index.htm" /> 
<add value="iisstart.htm" /> 
<add value="default.aspx" /> 
</files> 
</defaultDocument> 
<rewrite> 
<rules> 
<rule name="Hide .html ext"> 
<match url="^(.*)" ignoreCase="true" /> 
<conditions> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
<add input="{REQUEST_FILENAME}.html" matchType="IsFile" /> 
</conditions> 
<action type="Rewrite" url="{R:0}.html" /> 
</rule> 
<rule name="Redirecting .html ext" stopProcessing="true"> 
<match url="^(.*).html" /> 
<conditions logicalGrouping="MatchAny"> 
<add input="{URL}" pattern="(.*).html" /> 
</conditions> 
<action type="Redirect" url="{R:1}" /> 
</rule> 
</rules> 
</rewrite> 
</system.webServer> 
</configuration> 

回答

0

請確保您有安裝在您的IIS URL重寫功能。 see the image

如果它不可用,然後單擊獲取新的Web平臺組件在右手邊,搜索URL重寫並安裝它。重新打開IIS管理器。

點擊您的網站並打開URL重寫功能。您可以瀏覽web.config文件中的重寫規則。 see example here