.NET 301重定向规则问题-可能与其他规则冲突

时间:2018-09-16 17:53:52

标签: asp.net redirect iis web-config

我已经有一个“ http to https”规则和一个“ remove www”规则,并且正在运行。 请参阅代码末尾。 现在,我想添加另一个匹配“øwebsite.com”的规则并重定向到“ website.com”。注意特殊字符“ø”。不知道那是否重要。

看看我的另外两个工作规则,我发现这是怎么做的:

<rule name="øwebsite to website" enabled="true" stopProcessing="false">
          <match url=".*" ignoreCase="true" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^øwebsite\.com$" />
            <add input="{HTTPS}" pattern="^øwebsite\.com$" />
          </conditions>
          <action type="Redirect" url="https://website.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>

我将上述块放在其他两个规则之间,并在其他位置进行了“启用”属性的配置转换:

        <rule name="Redirect to https" stopProcessing="false" enabled="false">
      <match url="(.*)" ignoreCase="true" />
      <conditions >
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
        <add input="{HTTP_HOST}" pattern="localhost" negate="true"/>
        <add input="{HTTP_HOST}" pattern="staging" negate="true" />
        <add input="{HTTP_HOST}" pattern="development" negate="true" />
      </conditions>
      <action type="Redirect" url="https://website.com/{R:1}" redirectType="Permanent" />

<rule name="Removewww" stopProcessing="false" enabled="false">
      <match url="(.*)" negate="false"></match>
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www\.(.*)$" />
      </conditions>
      <action type="Redirect" url="https://website.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

我应该将我的新规则与这两个规则之一结合起来,还是只是在我的新规则中做错了什么?

0 个答案:

没有答案