【发布时间】:2017-01-04 02:35:29
【问题描述】:
我正在尝试将 IIS 8.5 Web 服务器上特定子文件夹的 HTTP 重写为 HTTPS,但它不起作用。我已经阅读了无数其他解决方案和博客文章,但我尝试过的都没有。
http://domain.example.com/one/two/three/
应该重定向到...(相同的网址,但使用 https)
https://domain.example.com/one/two/three/
而是重定向到...(使用 https 的站点根目录)
https://domain.example.com
正在加载...(带有 https 的所需网址)
https://domain.example.com/one/two/three/
还重定向到...(使用 https 的站点根目录)
https://domain.example.com
它正在从 url 中删除子文件夹。
此文件夹还需要使用 Windows 身份验证进行保护,我可以开始工作,但无论是否启用身份验证,https 重定向都会失败,所以我认为这不是原因。
在 IIS 中,我选择了所需的子文件夹(上例中的 /three/)并在那里创建了重写规则。
<rewrite>
<rules>
<clear />
<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
这当然适用于所需子文件夹中包含的任何文件和文件夹。 (/三)
我试过这个,它重定向到明显正确的 url,但给出“重定向太多”错误:
<rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="SeeOther" />
</rule>
【问题讨论】:
标签: redirect iis-8 url-rewrite-module