IIS7.5 也使用 https 将非 www 重定向到 www
IIS7.5 redirecting non www to www also with https
我正在尝试配置我的 IIS 以将所有 none www 调用重定向到 www 调用,包括 https
第一部分非常简单,但我还没有找到在您的绑定上启用 https 时也能正常工作的解决方案。
所以我两个都想要
http://domain.com/
和
https://domain.com/
和
http://www.domain.com/
全部重定向到:
有什么建议吗?
<rewrite>
<rules>
<rule name="Non www HTTP to HTTPS" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^www" negate="true" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" />
</rule>
<rule name="Non www HTTPS to www HTTPS" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="On" />
<add input="{HTTP_HOST}" pattern="^www" negate="true" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" />
</rule>
<rule name="HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="www*" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
@Josh:您的回答适用于第一个请求。
它将以“https://www”结尾,完美。
但是如果我然后从地址中删除 "www.",它将像下图一样失败。
This ended up working for me:
<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="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
我正在尝试配置我的 IIS 以将所有 none www 调用重定向到 www 调用,包括 https 第一部分非常简单,但我还没有找到在您的绑定上启用 https 时也能正常工作的解决方案。
所以我两个都想要 http://domain.com/ 和 https://domain.com/ 和 http://www.domain.com/ 全部重定向到:
有什么建议吗?
<rewrite>
<rules>
<rule name="Non www HTTP to HTTPS" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^www" negate="true" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" />
</rule>
<rule name="Non www HTTPS to www HTTPS" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="On" />
<add input="{HTTP_HOST}" pattern="^www" negate="true" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" />
</rule>
<rule name="HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="www*" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
@Josh:您的回答适用于第一个请求。 它将以“https://www”结尾,完美。 但是如果我然后从地址中删除 "www.",它将像下图一样失败。
This ended up working for me:
<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="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>