gpt4 book ai didi

IIS HTTP 到 HTTPS web.config 重写不返回整个 URL

转载 作者:行者123 更新时间:2023-12-02 01:13:12 25 4
gpt4 key购买 nike

所以我一直在尝试使用以下方法重写:

<rules>
<rule name="HttpToHttps" stopProcessing="true"/>
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{URL}"/>
</rule>
<rules>

在两个环境中,这会像它应该的那样重定向。在第三种环境中,它不起作用。它在某种意义上不起作用,看着 fiddler 日志,我看到带有完整 url 的 http 调用。当它重定向到 https 时,它会删除 HTTP_HOST 之后的所有内容。

因此使用以下网址:

nonsecure://www.mysite.com/page.aspx?var1=1&var2=2

在两种环境下,就变成了

secure://www.mysite.com/page.aspx?var1=1&var2=2

第三个变成:

secure://www.mysite.com

我尝试将其重写为 https://{HTTP_HOST}{HTTP_URL} 并且在前两个环境中将 {URL} 加倍:

secure://www.mysite.com/page.aspx?var1=1&var2=2&var1=1&var2=2

我对 web.configs 不是很有经验,有点学习,所以如果有人对这里发生的事情有任何意见,我将不胜感激。如果它有任何影响的话,第三个环境是在两台负载平衡的服务器上。

最佳答案

Ruslany 在他的博客上有几个 IIS URL 重写示例,HTTP 到 HTTPS 就是其中之一:

<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>

参见 http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/了解更多。

关于IIS HTTP 到 HTTPS web.config 重写不返回整个 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14925566/

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