gpt4 book ai didi

iis - 天蓝色网络应用程序: www to non www https

转载 作者:行者123 更新时间:2023-12-02 20:42:58 24 4
gpt4 key购买 nike

我有一个 Azure Web 应用程序,需要强制执行 https 方面的帮助。

https://www.example.comhttps://example.com

http://www.example.comhttps://example.com

www.example.com 至 https://example.com

example.com 至 https://example.com

当前的web.config如下。这不适用于 https://www.example.com -> https://example.com

<rules>


<!-- Force HTTPS for all requests -->
<rule name="HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>


<!-- Redirect all requests to non www-->
<rule name="WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://example.com{PATH_INFO}" />
</rule>

</rules>

最佳答案

根据你的url重写规则,我认为你的规则没有问题。虽然我没有配置自定义域,但我只是在我的 azure Web 应用程序上测试它,该应用程序只包含一些静态 html 文件和 web.config 文件,然后我强制它从 bruce-webapp.azurewebsites.net 重定向code> 到 https://azurewebsites.net 如下:

<rule name="Remove www" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(bruce-webapp\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://azurewebsites.net{PATH_INFO}"/>
</rule>

此外,请使用以下规则删除 www 前缀以缩小此问题的范围:

<rule name="Remove WWW prefix" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.yourdomain\.com$" />
</conditions>
<action type="Redirect" url="https://yourdomain.com/{R:1}" redirectType="Permanent" />
</rule>

如果以上尝试仍无法解决您的问题,您可以利用fiddler收集网络痕迹来解决此问题。另外,您可以使用更多详细信息(fiddler 网络痕迹或通过浏览器浏览时发生的情况)更新您的问题,以便我们定位此问题。

关于iis - 天蓝色网络应用程序: www to non www https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45503750/

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