ABC.com
www.ABC.cn
www.ABC.net
ABC.cn
ABC.net
上面五个都重定向到
www.ABC.com
IIS7以上可直接添加在web.config配置文件里面实现
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301-1 Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^ABC.com$" />
</conditions>
<action type="Redirect" url="http://www.ABC.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="301-2 Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^ABC.net$" />
</conditions>
<action type="Redirect" url="http://www.ABC.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="301-3 Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^ABC.cn$" />
</conditions>
<action type="Redirect" url="http://www.ABC.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="301-4 Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.ABC.net$" />
</conditions>
<action type="Redirect" url="http://www.ABC.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="301-5 Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.ABCcn$" />
</conditions>
<action type="Redirect" url="http://www.ABC.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<httpRedirect enabled="false" destination="http://www.ABC.com" exactDestination="true" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
解析设置:
第1种实现方式:记录类型为A记录,记录值为IP地址主机记录为@和WWW
第2种方式:如果买的是虚拟主机,一般在虚拟主机的具体信息上,可以查到别名,把服务商提供的这个别名做为记录值,记录类型为cname,主机记录为@和WWW,也可以实现