【发布时间】:2016-12-29 08:05:44
【问题描述】:
我有一个托管在 Microsoft Azure 网站上的 Angular 应用程序。我已通过为我安装扩展程序将所有请求自动重定向到 HTTPS 进行设置:https://github.com/gregjhogan/redirect-http-to-https-site-extension
扩展应用的作用是添加一个如下所示的 applicationhost.xdt 文件:
<?xml version="1.0" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="%XDT_SITENAME%" xdt:Transform="InsertIfMissing" xdt:Locator="Match(path)">
<system.webServer xdt:Transform="InsertIfMissing">
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing" lockElements="clear">
<rule name="redirect HTTP to HTTPS" enabled="true" stopProcessing="true" lockItem="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
现在一切正常,一切都被重定向到 HTTPS。现在我遇到了一个新要求,我想将重写规则编辑为以下内容:将所有请求重定向到 HTTPS(就像现在一样),但包含以下内容的任何 url 除外:“/#/user/[Some随机用户ID]”。
我已经阅读了不同的帖子,并尝试了一些不同的东西,但是 IIS 设置和类似的东西并不是我的领域,我正在努力寻找它。我觉得很接近的尝试是当我添加这个 {REQUEST_URI} 条件时:
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern=".*/#/user/.+" ignoreCase="true" />
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
</conditions>
我已尝试重新启动 Azure Web 应用程序并重新部署它,但它似乎没有启动,一切仍然重定向到 HTTPS,因为原始规则适用。
【问题讨论】:
标签: azure redirect iis web-config http-redirect