gpt4 book ai didi

http - 某些 URL 上的 URL 重写为 https

转载 作者:可可西里 更新时间:2023-11-01 16:56:11 25 4
gpt4 key购买 nike

我需要将 http 请求重定向到 https。但仅当通过普通 URL 访问我的站点时。即 www.accufinance.com

当我在本地调试中访问它时,我使用本地主机连接 - 并且不希望发生重写(因为我本地没有 SSL)。

我正在尝试:

<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url="^accufinance.com$" ignoreCase="true"/>
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>

但是重写规则不会发生。如果我使用 (.*) 作为匹配 URL,它工作正常,但会捕获所有连接。如何让规则仅在 URL 中包含“accufinance.com”时触发?

最佳答案

您需要检查 HTTP_HOST 的条件以匹配您的域名。
url 参数的指令 match 只包含您的域名后面的内容。

示例:http://www.domain.tld/some/url/here.ext

  • HTTP_HOST = www.domain.tld
  • REQUEST_URI = /some/url/here.ext

你可以使用这个规则做你想做的事

<rule name="Redirect to https" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)?accufinance\.com$" ignoreCase="true" />
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

请注意,在重试之前您需要清除浏览器的缓存(由于永久重定向,您的旧规则仍在缓存中)

关于http - 某些 URL 上的 URL 重写为 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25943540/

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