繁体   English   中英

重定向到 web 中的 HTTPS。 配置

[英]Redirecting to HTTPS in web. Config

我在 web 中添加了一条新规则。 配置文件重定向到 HTTPS。 它在本地主机上工作,但是一旦我将它部署到开发环境重定向就不起作用。 任何人都有任何解决方案来解决它。

<system.webServer>
<rewrite>
<rules>                   
<rule name="Force HTTPS" enabled="true" stopProcessing="true">    
<match url=".*" ignoreCase="false"/>
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">            
<add input="{HTTPS}" pattern="off"/>
</conditions>                 
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent"/>       
</rule>                     
</rules>                     
</rewrite>
</system.webServer>

使用此更新版本:

<rewrite> 
    <rules> 
    <rule name="HTTPS force" enabled="true" stopProcessing="true"> 
    <match url="(.*)" /> 
        <conditions> 
            <add input="{HTTPS}" pattern="^OFF$" /> 
        </conditions> 
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 

在我的解决方案中,我使用此配置并且它有效:

<rule name="HTTP to HTTPS redirect for all requests" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
                <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
        </rule>

我希望它是你的解决方案!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM