從優(yōu)化搜索引擎角度出發(fā),301重定向是網(wǎng)址重定向比較可行的一種辦法。當(dāng)網(wǎng)站的當(dāng)前域名不可用或者發(fā)生變更后,搜索引擎只對(duì)新網(wǎng)址進(jìn)行索引,同時(shí)又會(huì)把舊地址下原有的外部鏈接如數(shù)轉(zhuǎn)移到新地址下,從而不會(huì)讓網(wǎng)站的排名因?yàn)榫W(wǎng)址變更而收到絲毫影響。
同樣,在使用301永久性重定向命令讓多個(gè)域名指向網(wǎng)站主域時(shí),也不會(huì)對(duì)網(wǎng)站的排名產(chǎn)生任何負(fù)面影響。
301重定向有助于增加網(wǎng)站的權(quán)重,如將所有站點(diǎn)權(quán)重都集中于 一個(gè)域名
注意:要做重定向的域名一定都要綁定并解析在該主機(jī)上才能生效
一.下面簡(jiǎn)單闡述一下對(duì)Windows虛擬主機(jī)用戶的實(shí)現(xiàn)301重定向的方法:
例如:將7e.hk 定向到m.sh-ar.cn 這個(gè)域名上。
Windows server 2003 IIS6.0虛擬主機(jī)下301重定向代碼
httpd.ini文件 配置的代碼如下:
[php] [ISAPI_Rewrite] CacheClockRate 3600 RepeatLimit 32 RewriteCond Host: ^7e\.hk$ RewriteRule (.*) http\://www\.7e\.hk$1 [I,R] [/php]
下載地址:httpd.ini
復(fù)制以上代碼,寫入httpd.ini文件然后上傳到網(wǎng)站根目錄即可。記住把其中的7e.hk域名換成你的域名。
Windows server 2008 IIS7.5虛擬主機(jī)下的urlrewrtie規(guī)則
web.config文件代碼如下:
[php] <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="WWW Redirect" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^7e.hk$" /> </conditions> <action type="Redirect" url="http://m.sh-ar.cn/{R:0}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration> [/php]
下載地址:web.config
復(fù)制以上代碼,,寫入web.config文件然后上傳到網(wǎng)站根目錄即可。記住把其中的7e.hk域名換成你的域名。
二.多個(gè)域名重定向怎么處理?
當(dāng)然,被重定向的域名可以有多個(gè),該怎么處理。往下看。
1.httpd.ini 配置文件中需要另寫一行重定向代碼。
[php] [ISAPI_Rewrite] CacheClockRate 3600 RepeatLimit 32 RewriteCond Host: ^7e\.hk$ RewriteRule (.*) http\://www\.7e\.hk$1 [I,R] RewriteCond Host: ^idc.7e\.hk$ RewriteRule (.*) http\://www\.7e\.hk$1 [I,R] [/php]
2. web.config配置文件中只需在被重定向的域名后面加一個(gè)豎線"|"跟上需要被重定向的增加域名即可。
像這樣:
[php] <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="WWW Redirect" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^7e.hk|idc.7e.hk$" /> </conditions> <action type="Redirect" url="http://m.sh-ar.cn/{R:0}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration> [/php]