多域名301转向一个域名的写法如下:
其中pattern="^XX0.com|XX2.org$" 这里你想加几个都可以,中间用|隔开即可! =================================以下为具体代码============== <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^XX0.com|XX2.org$" />
</conditions>
<action type="Redirect" url="http://www.XX1.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Redirect mulu" stopProcessing="true">
<match url="^mulu1/$" />
<action type="Redirect" url="http://www.XX1.com/mulu2/" redirectType="Permanent" />
</rule>
<rule name="Redirect mulu1" stopProcessing="true">
<match url="^mulu1/(\d{4})/(\d{4})/(\d{3})\.html$" />
<action type="Redirect" url="http://www.XX1.com/mulu2/{R:1}/{R:2}/{R:3}.html" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
<add input="{HTTP_HOST}" pattern="^wsisp.net|wsisp.cn$" />
==============================以上为具体代码=========================
上面的这一段代码作用是,访问网站目录1直接301跳转到目录2,的单独一个URL的301重定向代码:
<match url="^mulu1/$" />
<action type="Redirect" url="http://www.XX1.com/mulu2/" redirectType="Permanent" />
以下代码是目录1下子目录及页面的通配,作用是将http://www.XX1.com/mulu1/2015/1111/001.html 定向到 http://www.XX1.com/mulu2/2015/1111/001.html的代码! 其中(\d{4})代表4为数字串、(\d{3})代表3为数字串。
<match url="^mulu1/(\d{4})/(\d{4})/(\d{3})\.html$" />
<action type="Redirect" url="http://www.XX1.com/mulu2/{R:1}/{R:2}/{R:3}.html" redirectType="Permanent" />
(责任编辑:砍传奇私服发布网) |