重定向到子域而不更改URL-IIS

时间:2017-11-07 01:57:18

标签: redirect iis url-rewriting web-config url-redirection

我们有一个网站 www.A.Com ,当我浏览网址 www.A.Com/loc 时 我需要重定向到由SEO提供商托管的子域 www.loc.A.Com 并显示由他们托管的页面。

主要要求是我们不应更改URL,即URL应保持 www.A.Com/loc

我们通过定义以下规则

尝试使用URL Write模块
<rewrite>
  <rules>
    <rule name="ProxyExample" stopProcessing="true">
      <match url="^locations/?(.*)" />
      <action type="Rewrite" url="http://A.Locations.com/{R:1}" />
      <serverVariables>
        <set name="HTTP_ACCEPT_ENCODING" value="" />
      </serverVariables>
    </rule>
  </rules>
</rewrite>

一个注意事项是我们的网站托管在Azure App Service上

1 个答案:

答案 0 :(得分:0)

如果您要移除serverVariables

,您的规则应该有效
<rule name="ProxyExample" stopProcessing="true">
  <match url="^locations/?(.*)" />
  <action type="Rewrite" url="http://A.Locations.com/{R:1}" />
</rule>