IIS10 http重定向https
我这边是windows server2019,自身没有url 重写,
官方下载一个重写模块:https://www.iis.net/downloads/microsoft/url-rewrite
配置后效果如下:

一、图形化界面
过程如下:
过程值:(.*)
条件:
{HTTPS} ^OFF$
{HTTPS_HOST} ^(localhost)

操作
https://{HTTP_HOST}/{R:1}

二、代码直接配置

<system.webServer> <rewrite> <rules> <rule name="http to https" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" /> <add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" /> </rule> </rules> </rewrite> <httpErrors errorMode="Detailed" /> <security> <requestFiltering> <hiddenSegments> <add segment="log" /> </hiddenSegments> </requestFiltering> </security> </system.webServer>

浙公网安备 33010602011771号