国产亚洲av在线,国产高清,欧美激情,国产精品久久久久7777,国产精品人成在线观看,国产精品永久免费视频

IT之道-艾銻知道

您當前位置: 主頁 > 資訊動態(tài) > IT知識庫 >

網(wǎng)站知識:什么是301跳轉(zhuǎn),301永久重定向,網(wǎng)站為什么要做301跳轉(zhuǎn)


2013-04-17 10:05 作者:admin

之前我發(fā)現(xiàn)成都地區(qū)一個比較知名的社區(qū)門戶網(wǎng)站,因為他們以前的域名太長不太好記因此換上了一個比較好記的新域名。讓我感到奇怪的是這個新域名在短占的時間百度收錄了上網(wǎng)頁,GOOGLE PR也到了5,當時不太明白,其實正是他們利用了301跳轉(zhuǎn)把老域名相應權(quán)重轉(zhuǎn)移到新域名。

通過上例,首先我們了解一下什么是301跳轉(zhuǎn)?301跳轉(zhuǎn),也叫301重定向,301轉(zhuǎn)向。指的是當用戶點擊一個網(wǎng)址時,通過技術(shù)手段,跳轉(zhuǎn)到指定的另一個網(wǎng)站。

301跳轉(zhuǎn),一般用于二個域名指向同一個網(wǎng)站,一般來說,利用跳轉(zhuǎn),對網(wǎng)站的排名不會有影響(但最好還是一站一域名)。

不過這里要說明一下,并不是通過301跳轉(zhuǎn)就能使權(quán)重完全轉(zhuǎn)移的,這個還有很多因素決定。301只能說可以讓損失減少到最低。

下面給大家減少一下301的具體設(shè)置方式

1、IIS下301設(shè)置

Internet信息服務管理器 -> 虛擬目錄 -> 重定向到URL,輸入需要轉(zhuǎn)向的目標URL,并選擇“資源的永久重定向”。

2、ASP下的301轉(zhuǎn)向代碼

<%@ Language=VBScript %>

<%

Response.Status=”301 Moved Permanently”

Response.AddHeader “Location”, “http://www.gzjlwl.net/html/301/”

%>

3、ASP.Net下的301轉(zhuǎn)向代碼

<script runat=”server”>

private void Page_Load(object sender, System.EventArgs e)

{

Response.Status = “301 Moved Permanently”;

Response.AddHeader(”Location”,”http://www.yuchentang.com/html/301/“);

}

</script>

4、PHP下的301轉(zhuǎn)向代碼

header(”HTTP/1.1 301 Moved Permanently”);

header(”Location: http://www.yuchentang.com/html/301/”);

exit();

5、CGI Perl下的301轉(zhuǎn)向代碼

$q = new CGI;

print $q->redirect(”http://www.yuchentang.com”);

6、JSP下的301轉(zhuǎn)向代碼

<%

response.setStatus(301);

response.setHeader( “Location”, “http://www.yuchentang.com” );

response.setHeader( “Connection”, “close” );

%>

7、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.yuchentang.com$1 [L,R=301]

2)重定向到新域名

Options +FollowSymLinks

RewriteEngine on

RewriteRule ^(.*)$ http://www.yuchentang.com/html$1 [L,R=301]

3)使用正則進行301轉(zhuǎn)向,實現(xiàn)偽靜態(tài)

Options +FollowSymLinks

RewriteEngine on

RewriteRule ^news-(.+)\.html$ news.php?id=$1

將news.php?id=123這樣的地址轉(zhuǎn)向到news-123.html

8、Apache下vhosts.conf中配置301轉(zhuǎn)向

為實現(xiàn)URL規(guī)范化,SEO通常將不帶WWW的域名轉(zhuǎn)向到帶WWW域名,vhosts.conf中配置為:

<VirtualHost *:80>

ServerName www.yuchentang.com

DocumentRoot /home/lesishu

</VirtualHost>

<VirtualHost *:80>

ServerName lesishu.cn

RedirectMatch permanent ^/(.*) http://www.yuchentang.com/$1

</VirtualHost>

 

   

相關(guān)文章

IT外包服務
二維碼 關(guān)閉