帮助中心 >  技术知识库 >  云服务器 >  IIS的使用和管理 >  IIS站点上多个域名做不同301跳转的实现

IIS站点上多个域名做不同301跳转的实现

2018-04-22 07:11:51 15932

比如我在一台主机上的IIS站点绑定了两个域名a.com和b.com,现在都要做301要指向不同网址,那么如何写web.config呢?代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
<rules>
<rule name="301-1" stopProcessing="true">
<match url=".*" />
<conditions>
            <add input="{HTTP_HOST}" pattern="^a.com$" />
</conditions>
<action type="Redirect" url="a.com要跳转的域名/{R:0}" 
redirectType="Permanent" />
</rule>
<rule name="301-2" stopProcessing="true">
<match url=".*" />
<conditions>
            <add input="{HTTP_HOST}" pattern="^b.com$" />
</conditions>
<action type="Redirect" url="b.com要跳转的域名/{R:0}" 
redirectType="Permanent" />
</rule>
</rules>
    </rewrite>
 <system.webServer>
 </configuration>


提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: