RewriteCond為條件,多域名時多復制一行即可
iis6規則
在主機面板-網站基本功能中,點擊isapi篩選器,點擊第二個按鈕”開啟自定義url偽靜態支持”,然后通過文件管理進入
others/discuz/httpd.conf中,強兩行保留,其余代碼刪除,并復制以下代碼到該文件中保存即可
RewriteCond %{HTTP:Host} ^xxxx1.com$?[NC]
RewriteCond %{HTTP:Host} ^xxxx2.com$?[NC]
RewriteRule (.*) http://www.xxxx1.com$1 [NC,R=301]
實現的效果是xxxx1.com和xxxx2.com訪問時跳轉到www.xxxx1.com
iis7規則
在主機面板-文件管理,進入wwwroot,新建一個文件,命名web.config,復制一些規則,保存即可
<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”301Redirect” stopProcessing=”true”>
<match url=”(.*)” />
<conditions logicalGrouping=”MatchAny”>
<add input=”{HTTP_HOST}” pattern=”^xxxx1.com$” />
<add input=”{HTTP_HOST}” pattern=”^xxxx2.com$” />
</conditions>
<action type=”Redirect” url=”http://www.xxxx1.com/{R:0}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
實現的效果是xxxx1.com和xxxx2.com訪問時跳轉到www.xxxx1.com
其中三五互聯的虛機主機,已開發“301”轉向功能,可快捷設置,相對手工設置,管理更簡單便捷。三五互聯虛機主機鏈接:http://m.shinetop.cn/services/webhosting/