DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁SEO優化 >  >> SEO優化集錦
301 與 302 差在哪?各平台轉址設定一次看
編輯:SEO優化集錦     

網頁跳轉大致有三種做法:後端程式(ASP、PHP 等)、HTML 的 meta refresh,以及 JavaScript 跳轉。其中 meta 與 JS 屬於 302 性質的暫時性跳轉。

如果網頁位址已經永久搬移,301 重定向是對搜尋引擎最友善的方式;只要不是暫時搬移,都建議用 301 做轉址,因為權重能完整繼承。

ASP

<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "https://www.yourdomain.com"
%>

PHP

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: https://www.yourdomain.com" );
?>

ASP.NET

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", "https://www.yourdomain.com");
}
</script>

Apache:httpd.conf 或 .htaccess

# 將整個目錄下的內容導向新站對應位置
Redirect permanent / https://www.yourdomain.com/

# 將首頁導向指定檔案
Redirect permanent / https://www.yourdomain.com/404.htm

關鍵在 permanent 這個字。少了它一樣會跳轉,但那屬於 302 暫時性重定向,權重不會移轉。

IIS

1. 開啟「網際網路資訊服務管理員」,在要重定向的網頁或目錄上按右鍵。
2. 選擇「重定向到 URL」。
3. 在「重定向到」欄位填入目標網址。
4. 勾選「資源的永久重定向」(這一步最關鍵)。
5. 點擊「確定/套用」。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved