iis - 用于多域托管的 web.config https 重定向
问题描述
我有一个 GoDaddy 多网站托管帐户,现在我已经实施了 SSL,我希望所有具有 SSL 的域现在都重定向到 https。GoDaddy 说 web.config 需要修改,但他们没有关于如何为多个域执行此操作的示例。
我已经尝试了以下代码,该代码适用于托管帐户上的主域 (domainA),但随后它弄乱了该帐户上托管的所有其他域的所有 URL。例如http://domainA.com重定向到https://domainA.com但使用此代码实现http://domainB.com重定向到https://domainB.com/domainB/ - domainB 是子文件夹存储其他域文件。
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
解决方案
尝试https://{HTTP_HOST}{REQUEST_URI}
你的行动。
此外,我会在测试时使用临时而非永久重定向。您的浏览器可能会缓存错误的重定向,这可能会非常令人沮丧,因此请务必清除缓存或使用私人浏览器窗口来测试更改。
推荐阅读
- python - DataFrame 行的多条件搜索返回空结果
- php - 未采取 Gmail 操作的 PHPMailer
- c++ - 编译 GLFW 代码时参数无效?
- ios - iOS 视频缓存 - 手动缓存删除
- automated-tests - 空手道 - 输入字段/文本区域清除字段无法正常工作
- javascript - 我可以在条件下使用正则表达式吗?我如何为以辅音开头的单词和以 Javascript 中以元音开头的单词做条件
- filtering - 高级标签过滤不适用于同一集合中选择的多个标签
- python - 在分隔符上拆分 pandas df 行,然后根据索引重命名另一行
- php - Laravel 6 无域名路由
- javascript - 如何从 Typescript 中的字典对象中获取匹配值?