教你如何做301 重定向
教你如何做301 重定向301 轉(zhuǎn)向代碼的各種寫法來源:商渡網(wǎng)(www.33w.net.cn )301 代表永久性轉(zhuǎn)移(Permanently Moved),301 重定向是網(wǎng)頁更改地址后對搜索引擎友
教你如何做301 重定向
301 轉(zhuǎn)向代碼的各種寫法
來源:商渡網(wǎng)(www.33w.net.cn )
301 代表永久性轉(zhuǎn)移(Permanently Moved),301 重定向是網(wǎng)頁更改地址后對搜索引擎友好的最好方法, 羅嗦話我也不說了, 既然你看了這篇文章, 你應(yīng)該是懂的 301 的具體意思了, 下面就說說301轉(zhuǎn)向代碼的各種寫法吧:
一: IIS中實現(xiàn)301轉(zhuǎn)向:
1. 打開internet 信息服務(wù)管理器,在欲重定向的網(wǎng)頁或目錄上按右鍵
2. 選中“重定向到URL”
3. 在對話框中輸入目標頁面的地址
4. 選中“資源的永久重定向”
5. 點擊“應(yīng)用”即可生效
二:ASP下的301轉(zhuǎn)向代碼:
ASP 下的301轉(zhuǎn)向代碼:
<@ Language="VBScript" >
<
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.mf591.com" >
代碼使用方法可參見本人以前寫的關(guān)于 301永久重定向的
,文章.
三:PHP下的301轉(zhuǎn)向代碼:
PHP 下的301轉(zhuǎn)向代碼:
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.mf591.com");
exit();
?>
四:ASP.Net下的301轉(zhuǎn)向代碼:
ASP.Net 下的301轉(zhuǎn)向代碼:
,五:CGI Perl下的301轉(zhuǎn)向代碼:
CGI Perl下的301轉(zhuǎn)向代碼:
$q = new CGI;
print $q->redirect("http://www.mf591.com");
六:JSP下的301轉(zhuǎn)向代碼:
JSP 下的301轉(zhuǎn)向代碼:
<
response.setStatus(301);
response.setHeader( "Location", "http://www.mf591.com" ); response.setHeader( "Connection", "close" );
>
七:Apache下301轉(zhuǎn)向代碼:
新建.htaccess 文件,輸入下列內(nèi)容(需要開啟 mod_rewrite) :
,1)將不帶WWW 的域名轉(zhuǎn)向到帶WWW 的域名下: Options FollowSymLinks
RewriteEngine on
RewriteCond {HTTP_HOST} ^lesishu.cn [NC]
RewriteRule ^(.*)$ http://www.mf591.com/$1 [L,R=301]
2) 重定向到新域名:
Options FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.mf591.com/$1 [L,R=301]
八:Apache下vhosts.conf 中配置301轉(zhuǎn)向:
為實現(xiàn)URL 規(guī)范化,SEO 通常將不帶WWW 的域名轉(zhuǎn)向到帶 WWW 域名,vhosts.conf 中配置為:
Apache 下vhosts.conf 中配置301轉(zhuǎn)向:
ServerName www.mf591.com DocumentRoot /home/lesishu
ServerName mf591.com
RedirectMatch permanent ^/(.*) http://www.mf591.com/$1
,九:Ruby中實現(xiàn)301轉(zhuǎn)向:
Ruby 中實現(xiàn)301轉(zhuǎn)向:
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.mf591.com"
end
十:Coldfusion中實現(xiàn)301轉(zhuǎn)向:
Coldfusion 中實現(xiàn)301轉(zhuǎn)向:
<.cfheader statuscode="301" statustext="Moved permanently"> <.cfheader name="Location" value="http://www.mf591.com"> 附:301轉(zhuǎn)向情況檢測地址
若出現(xiàn)以下內(nèi)容則301永久轉(zhuǎn)向成功:
英文:
Response
,Checked link: http://mf591.com
Type of redirect: 301 Moved Permanently Redirected to: http://www.mf591.com
翻譯成中文是:
中文:
檢查鏈接: http://mf591.com
類型重定向: 301永久移動
重定向到: http://www.mf591.com