之前我發現成都地區一個比較知名的社區門戶網站,因為他們以前的域名太長不太好記因此換上了一個比較好記的新域名。讓我感到奇怪的是這個新域名在短占的時間百度收錄了上網頁,GOOGLE PR也到了5,當時不太明白,其實正是他們利用了301跳轉把老域名相應權重轉移到新域名。
通過上例,首先我們了解一下什么是301跳轉?301跳轉,也叫301重定向,301轉向。指的是當用戶點擊一個網址時,通過技術手段,跳轉到指定的另一個網站。
301跳轉,一般用于二個域名指向同一個網站,一般來說,利用跳轉,對網站的排名不會有影響(但最好還是一站一域名)。
不過這里要說明一下,并不是通過301跳轉就能使權重完全轉移的,這個還有很多因素決定。301只能說可以讓損失減少到最低。
下面給大家減少一下301的具體設置方式
1、IIS下301設置
Internet信息服務管理器 -> 虛擬目錄 -> 重定向到URL,輸入需要轉向的目標URL,并選擇“資源的永久重定向”。
2、ASP下的301轉向代碼
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.gzjlwl.net/html/301/”
%>
3、ASP.Net下的301轉向代碼
<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轉向代碼
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: http://www.yuchentang.com/html/301/”);
exit();
5、CGI Perl下的301轉向代碼
$q = new CGI;
print $q->redirect(”http://www.yuchentang.com”);
6、JSP下的301轉向代碼
<%
response.setStatus(301);
response.setHeader( “Location”, “http://www.yuchentang.com” );
response.setHeader( “Connection”, “close” );
%>
7、Apache下301轉向代碼
新建.htaccess文件,輸入下列內容(需要開啟mod_rewrite):
1)將不帶WWW的域名轉向到帶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轉向,實現偽靜態
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news-(.+)\.html$ news.php?id=$1
將news.php?id=123這樣的地址轉向到news-123.html
8、Apache下vhosts.conf中配置301轉向
為實現URL規范化,SEO通常將不帶WWW的域名轉向到帶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>
相關文章