And*_*ndi 12 rewrite iis-7 url https redirect
我的网站有两个绑定:1000 和 1443 (端口 80/443 被同一 IIS 实例上的另一个网站使用)。端口 1000 是 HTTP,端口 1443 是 HTTPS。我想要做的是使用“htt p://server:1000”将任何传入请求重定向到"https://server:1443". 我正在玩 IIS 7 重写模块 2.0,但我正在用头撞墙。任何见解表示赞赏!
顺便说一句,下面的重写配置适用于在端口 80 上具有 HTTP 绑定和在端口 443 上具有 HTTPS 绑定的站点,但它不适用于我的端口。
PS 我的 URL 故意留有空格,因为“垃圾邮件预防机制”启动了。出于某种原因,谷歌登录不再工作,所以我不得不创建一个 OpenID 帐户(没有脚本可能是罪魁祸首)。我不确定如何让 XML 显示得很好,所以我在左括号后添加了空格。
< ?xml version="1.0" encoding="utf-8"?>
< configuration>
< system.webServer>
< rewrite>
< rules>
< rule name="HTTP to HTTPS redirect" stopProcessing="true">
< match url="(.*)" />
< conditions trackAllCaptures="true">
< add input="{HTTPS}" pattern="off" />
< /conditions>
< action type="Redirect" redirectType="Found" url="htt ps: // {HTTP_HOST}/{R:1}" />
< /rule>
< /rules>
< /rewrite>
< /system.webServer>
< /configuration>
Run Code Online (Sandbox Code Playgroud)
小智 12
虽然这个问题已经回答了一段时间,但这是我使用的规则。
<rule name="Redirect to HTTP on different port" enabled="true" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="ON"/>
</conditions>
<!-- Cannot Use {HTTP_HOST} as it contains both the {SERVER_NAME}{SERVER_PORT} -->
<action type="Redirect" url="http://{SERVER_NAME}:1000{HTTP_URL}" redirectType="Found" appendQueryString="false"/>
</rule>
Run Code Online (Sandbox Code Playgroud)
<rule name="HTTP to HTTPS on different SSL Port" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="([^/:]*?):[^/]*?" />
</conditions>
<action type="Redirect" url="https://{C:1}:1443/{R:0}" appendQueryString="false" />
</rule>
Run Code Online (Sandbox Code Playgroud)
这解决了我的问题。
尝试改变这个:
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/>
Run Code Online (Sandbox Code Playgroud)
对此:
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}:1443/{R:1}"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31144 次 |
| 最近记录: |