apache、iis設(shè)置301教程(適用虛擬主機)當(dāng)前提供教程是通過重寫規(guī)則實現(xiàn)301,目前我司主機面板已經(jīng)開發(fā)"301轉(zhuǎn)向"功能可快捷設(shè)置: 如果部署了https訪問,請忽略此教程,部署https的網(wǎng)站請參考:http://ps-sw.cn/faq/list.asp?unid=1419
2.2 linux系統(tǒng): 左側(cè)選框中選擇需要進行跳轉(zhuǎn)的域名,若多個域名,則拖動多選或按ctrl鍵點擊 右側(cè)選框中輸入需要跳轉(zhuǎn)到的域名,下面會顯示生成的301代碼,需要通過網(wǎng)站基本功能-文件管理-wwwroot下創(chuàng)建一個文件,命名.htaccess(若已有,只需要復(fù)制代碼添加進去),復(fù)制生成的代碼粘貼到.htaccess中保存即可 手工設(shè)置301的方法如下: apache規(guī)則在主機面板-文件管理,進入wwwroot,新建一個文件,命名為.htaccess文件,寫入以下規(guī)則,保存即可 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xxxx1.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^xxxx2.com$ [NC]
RewriteRule ^(.*)$ http://www.xxxx1.com/$1 [R=301,L]
</IfModule>實現(xiàn)的效果是xxxx.com訪問時跳轉(zhuǎn)到www.xxxx.com RewriteCond為條件,多域名時多復(fù)制一行即可 iis規(guī)則 在主機面板-文件管理,進入wwwroot,新建一個文件,命名web.config,復(fù)制一些規(guī)則,保存即可 <?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>實現(xiàn)的效果是xxxx1.com和xxxx2.com訪問時跳轉(zhuǎn)到www.xxxx1.com
|
|||||
| >> 相關(guān)文章 | |||||
|
|
|||||