iis ASP.NET MVC URL重写- WWW重定向

d6kp6zgx  于 9个月前  发布在  .NET
关注(0)|答案(1)|浏览(121)

我正在尝试添加一个iis网址重写规则在web.xml中。规则应如下。
如果URL不包含www,然后重定向到www然而,如果主机包含,'svha-prd-as-carervices-01'然后不重定向到www
下面是我的代码,www重定向工作,但是,否定条件检查'svha-prd-as-carervices-01'不工作。我错过了什么?

<rule name="Redirect Non-WWW to WWW" enabled="true" stopProcessing="true">
                  <match url=".*" />
                  <conditions>
                    <add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)" />
                    <add input="{REQUEST_HOST}" pattern="^(.*)svha-prd-as-careservices-01(.*)" negate="true" />
                  </conditions>
                  <action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
3wabscal

3wabscal1#

请检查规则中的第二个条件:

<add input="{REQUEST_HOST}" pattern="^(.*)svha-prd-as-careservices-01(.*)" negate="true" />

您可能错误地将{REQUEST_URI}写成了{REQUEST_HOST}。
请将其修改为正确的条件,然后重试:

<add input="{REQUEST_URI}" pattern="^(.*)svha-prd-as-careservices-01(.*)" negate="true" />

相关问题