简体   繁体   English

IIS 8.5将非www重定向到www不起作用

[英]IIS 8.5 redirect non www to www not working

Here's the relevant bit of my Web.Config: 这是我的Web.Config的相关部分:

<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAny">
      <add input="{HTTP_HOST}" pattern="^[^www]" />
      <add input="{HTTPS}" pattern="off" />
  </conditions>
  <action type="Redirect" url="https://www.zzz.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

It will rewrite http to https but will not add the www as needed by my cms. 它将http重写为https,但不会按我的cms的需要添加www。 I've tried several variants of this and it just seems that IIS 8.5 on Win2012R2 refuses to follow the www rule. 我已经尝试了几种变体,但似乎Win2012R2上的IIS 8.5拒绝遵循www规则。 Any ideas? 有任何想法吗?

The problem comes from the pattern used to detected non-www. 问题来自用于检测到非www的模式。
You sould replace it like this : 您可以像这样替换它:

<add input="{HTTP_HOST}" pattern="^zzz.com$" />

遇到相同的问题后,我通过编辑网站的绑定并为zzz.com(仅针对http)添加了额外的绑定来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM