自架的IIS 要先安裝這個套件
URL Rewrite
如果在azure上的app就不需要
然後在web.config下的 [system.webServer] 區段
填入以下內容
[rewrite]
[rules]
[rule name="HTTP to HTTPS redirect" stopprocessing="true"]
[match url="(.*)"]
[conditions]
[add ignorecase="true" input="{HTTPS}" pattern="off"]
[/add][/conditions]
[action redirecttype="Found" type="Redirect" url="https://{HTTP_HOST}/{R:1}"]
[/action][/match][/rule]
[/rules]
[/rewrite]
URL Rewrite
如果在azure上的app就不需要
然後在web.config下的 [system.webServer] 區段
填入以下內容
[rewrite]
[rules]
[rule name="HTTP to HTTPS redirect" stopprocessing="true"]
[match url="(.*)"]
[conditions]
[add ignorecase="true" input="{HTTPS}" pattern="off"]
[/add][/conditions]
[action redirecttype="Found" type="Redirect" url="https://{HTTP_HOST}/{R:1}"]
[/action][/match][/rule]
[/rules]
[/rewrite]
留言