【问题标题】:IIS URL Rewrite with multiple domains具有多个域的 IIS URL 重写
【发布时间】:2020-10-24 11:00:03
【问题描述】:

我创建了一个新的 iis 网站,其主要 url 是每个示例:www.test.com

我为我的产品页面创建了这条规则:

 <rule name="products" enabled="true" stopProcessing="true"  >

      <match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />

      <action type="Rewrite" url="product.aspx?lan={R:0}&amp;cod={R:1}&amp;lib={R:2}" />

      <conditions logicalGrouping="MatchAny">
        <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
      </conditions>

    </rule>

这个网址http://www.test.com/fr/products/5858/tomato 工作正常。

但现在它想像这样使用不同的域扩展:

http://www.test.fr/products/5858/tomtato

在我的 DNS 中,http://www.test.com 和 http://www.test.fr 使用相同的 ip。

如何使用重写规则来管理这个?

【问题讨论】:

  • 您的问题解决了吗?如果您的问题得到解决,那么我请求您将有用的建议标记为答案。这将帮助面临同样问题的其他人。

标签: asp.net url iis url-rewriting


【解决方案1】:

要匹配 iis URL 重写规则中的域名,您可以使用服务器变量 {HTTP_HOST}。

<rule name="products" enabled="true" stopProcessing="true">

  <match url="^fr/products/([_0-9a-z-]+)/([_0-9a-z-]+)" />

  <action type="Rewrite" url="product.aspx?lan={R:0}&amp;cod={R:1}&amp;lib={R:2}" />

  <conditions logicalGrouping="MatchAny">
                    <add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|svg|jpeg|js|flv|f4v)$" negate="true" />
                    <add input="{HTTP_HOST}" pattern="^www.test.com$" />
  </conditions>

</rule>

【讨论】:

    猜你喜欢
    • 2016-04-25
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 2010-10-17
    相关资源
    最近更新 更多