【问题标题】:URL Rewrite Rule to remove www. for all URLs except for 1URL 重写规则以删除 www。对于除 1 之外的所有 URL
【发布时间】:2015-10-22 16:26:11
【问题描述】:

我有一个删除 www 的工作规则。对于所有进入的网址。我有一个网络服务,重定向将从 POST 更改为 GET。我需要从这条规则中排除 URL https://www.foo.net/WebServices/service.asmx

我查看了关于 SO 的其他解决方案,但没有成功。

  <rewrite>
      <rules>
          <rule name="Remove WWW" enabled="true" stopProcessing="true">
              <match url=".*"/>
              <conditions>
                    <add input="{HTTP_HOST}" pattern="^(www\.)(foo\.net)" />
              </conditions>
              <action type="Redirect" url="https://{C:2}/{R:1}" />
          </rule>
      </rules>
  </rewrite>    

【问题讨论】:

    标签: url-rewriting iis-7.5


    【解决方案1】:

    您可以通过向“不匹配”添加条件(也就是添加“negate='true'”)轻松做到这一点,这样的事情应该可以工作:

      <rules>
          <rule name="Remove WWW" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.foo\.net$" />
                        <add input="{URL}" pattern="^/WebServices/service\.asmx$" negate="true" />
              </conditions>
              <action type="Redirect" url="https://foo.net/{R:1}" />
          </rule>
      </rules>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      相关资源
      最近更新 更多