我正在尝试将所有http流量重定向到https,同时返回301状态代码。由于某种原因,我改为获得307状态,但我不知道为什么。我试图搜索以查看是否丢失了配置中的某些内容,但这似乎与我看到的所有内容相似。
我的web.config
<rewrite>
<rules>
<rule name="ForceWWW" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^MY_DOMAINE" />
</conditions>
<action type="Redirect" url="https://www.MY_DOMAINE/{R:0}" redirectType="Permanent" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>
更新
我刚刚发现了一些有趣的东西。例如我的域名是domaine.com
如果我搜索:
domaine.com重定向为301
http://www.domaine.com的重定向是307
www.domaine.com重定向为307
更新
我只遇到了Chrome的问题。其他浏览器的301状态带有重定向。