Iis 通过web.config中的URL重写强制HTTPS
我正试图通过web.config URL重写规则强制HTTPS重写包含路径的URL 乙二醇必须强制使用 我还想强制对其相对路径上的所有页面使用HTTPS 例如,http://my.domain.com/folder/page.aspx被迫使用https://my.domain.com/folder/page.aspx 这就是我所拥有的:Iis 通过web.config中的URL重写强制HTTPS,iis,azure,url-rewriting,web-config,Iis,Azure,Url Rewriting,Web Config,我正试图通过web.config URL重写规则强制HTTPS重写包含路径的URL 乙二醇必须强制使用 我还想强制对其相对路径上的所有页面使用HTTPS 例如,http://my.domain.com/folder/page.aspx被迫使用https://my.domain.com/folder/page.aspx 这就是我所拥有的: <rewrite> <rules> <rule name="Redirect to https">
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="Off"/>
<add input=”{REQUEST_METHOD}” pattern=”^get$|^head$” />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
</rules>
</rewrite>
检查您的大小写和使用的引号类型。另外,第二个输入法无效-该模式对于正则表达式无效。此规则适用于您想要的:
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
尝试此URL重写规则:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
谢谢!我也尝试过类似的方法,但经验是它重定向到https://my.domain.com,而没有跟踪路径