IIS 配置 HTTP 自动跳转到 HTTPS
To enable HTTP Strict Transport Security (HSTS) in IIS, need to add the appropriate headers to your web server's configuration:
- Open IIS Manager: Start by opening the Internet Information Services (IIS) Manager.
- Select Your Site: In the Connections pane, expand the node for your server, and then expand the Sites node. Select the site you want to configure.
- Open HTTP Response Headers: In the Features View, double-click on the "HTTP Response Headers" feature.
- Add HSTS Header: In the Actions pane on the right, click on "Add..." to add a new HTTP response header. Use the following settings:
- Name:
Strict-Transport-Security - Value:
max-age=31536000; includeSubDomains
This configuration sets the HSTS policy to a max age of one year and includes all subdomains.
Here's a sample configuration code for adding the HSTS header using theweb.configfile:
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
This code should be placed within the <configuration> section of your web.config file.
5. Restart IIS

浙公网安备 33010602011771号