gpt4 book ai didi

azure - 在 Azure 网站上强制使用 https - web.config - Laravel 4

转载 作者:太空宇宙 更新时间:2023-11-03 13:16:39 25 4
gpt4 key购买 nike

我正在尝试对所有流量强制使用 https。

我尝试了在互联网和微软自己的网站上找到的许多 web.config 规则,但似乎没有一个规则能够重定向到 https。

我不知道是否有什么变化导致所有这些规则无效,但无论如何它都不起作用。

这是我迄今为止检查过的内容:

 <rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />

 <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>
<小时/>
      <rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

来自: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure-ssl-certificate/

有什么想法吗?

提前致谢!

最佳答案

好的 - 只是在这个问题上浪费了 2 个小时,但答案非常微妙。

我在 azure 网站上运行 laravel4,要使其正常工作,需要两个 web.config 文件:一个位于“site/wwwroot/public”文件夹中,另一个位于“site/wwwroot”文件夹中。

我的问题是我忘记了这一点,只是修改了公共(public)文件夹中的内容。

解决方案是将规则添加到 site/wwwroot 中的 web.config 文件中,而不是添加到 site/wwwroot/public 中。

我还没有测试我之前提到的所有规则,但采用了微软建议的规则,并且它有效。

祝你好运。

<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

关于azure - 在 Azure 网站上强制使用 https - web.config - Laravel 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33441877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com