如何从 IIS 重定向规则中排除 Azure 插槽
How to exclude Azure slots from IIS Redirect Rule
我有一个由 Azure 托管的网站,我有 2 个主插槽和暂存插槽。我写了一个将非 www 重定向到 www 的条件,如下所示:
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
我的问题是这条规则也适用于暂存槽,就像我输入 https://mydomain-staging.azurewebsites.net it redirect me to https://www.mydomain-staging.azurewebsites.net 所以我无法测试我的暂存槽!
我需要编写一条规则来排除以 azurewebsites.net
结尾的广告位
我遵循了 的答案,但它对我不起作用。
几种方法。您可以指定要重定向的域,而不是包罗万象的 (.*)。
另一种方法是设置一个条件,如果主机名匹配 *.azurewebsites.net ,忽略
我通过添加这个条件解决了它:
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
<add input="{HTTP_HOST}" negate="true" pattern="^.*\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
我有一个由 Azure 托管的网站,我有 2 个主插槽和暂存插槽。我写了一个将非 www 重定向到 www 的条件,如下所示:
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
我的问题是这条规则也适用于暂存槽,就像我输入 https://mydomain-staging.azurewebsites.net it redirect me to https://www.mydomain-staging.azurewebsites.net 所以我无法测试我的暂存槽!
我需要编写一条规则来排除以 azurewebsites.net
我遵循了
几种方法。您可以指定要重定向的域,而不是包罗万象的 (.*)。 另一种方法是设置一个条件,如果主机名匹配 *.azurewebsites.net ,忽略
我通过添加这个条件解决了它:
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
<add input="{HTTP_HOST}" negate="true" pattern="^.*\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>