跳到主要內容

發表文章

目前顯示的是 1月, 2021的文章

對html網站移除.html副檔名 (Remove .html extension from URLs using url rewrite in IIS 8 for html website)

在Web.config中加入下列的rewrite URL設定即可 [rewrite] [rules] [rule name="Hide .html ext"] [match ignorecase="true" url="^(.*)"] [conditions] [add input="{REQUEST_FILENAME}" matchtype="IsFile" negate="true"] [add input="{REQUEST_FILENAME}" matchtype="IsDirectory" negate="true"] [add input="{REQUEST_FILENAME}.html" matchtype="IsFile"] [/add][/add][/add][/conditions] [action type="Rewrite" url="{R:0}.html"] [/action][/match][/rule] [rule name="Redirecting .html ext" stopprocessing="true"] [match url="^(.*).html"] [conditions logicalgrouping="MatchAny"] [add input="{URL}" pattern="(.*).html"] [/add][/conditions] [action type="Redirect" url="{R:1}"] [/action][/match][/rule] [/rules] [/rewrite] 參