【问题标题】:IIS URL Rewrite remove folder and redirect to other domainIIS URL 重写删除文件夹并重定向到其他域
【发布时间】:2017-02-27 20:14:29
【问题描述】:

我有两个域,www.example.com 和 www.example.xx。

当我访问 example.com 并更改语言时,我的地址更改为 example.com/xx。在这种情况下,我想重定向做另一个域后缀,例如 example.xx。但我仍然想转发完整的地址路径。

例如:http://example.com/xx/one/two/three/four/five/?query=string 应该重定向到 http://example.xx/one/two/three/four/five/?query=string

我尝试了几种方法,但都没有成功。

<rewrite>
  <rules>
    <rule name=".com xx Redirect" stopProcessing="true">
      <match url="(www\.)?example\.com\/xx\/.*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_URI}" pattern="^xx\/(.*)" />
      </conditions>
      <action type="Redirect" url="http://example.xx/{C:1}" appendQueryString="true" redirectType="Temporary" />
    </rule>
  </rules>
</rewrite>

【问题讨论】:

    标签: url redirect iis url-rewriting rule


    【解决方案1】:

    match url 只匹配路径而不匹配域。你将不得不做这样的事情:

    <rule name=".com xx Redirect" stopProcessing="true">
    <match url="^xx/(.*)" />
    <conditions >
      <add input="{HTTP_HOST}" pattern="^(www\.)?example\.com$" ignoreCase="true" />
    
    </conditions>
    <action type="Redirect" url="http://example.xx/{R:1}" appendQueryString="true" />
    

    【讨论】:

    猜你喜欢
    • 2013-10-16
    • 2016-09-23
    • 2017-02-13
    • 2016-05-03
    • 1970-01-01
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多