網頁跳轉大致有三種做法:後端程式(ASP、PHP 等)、HTML 的 meta refresh,以及 JavaScript 跳轉。其中 meta 與 JS 屬於 302 性質的暫時性跳轉。
如果網頁位址已經永久搬移,301 重定向是對搜尋引擎最友善的方式;只要不是暫時搬移,都建議用 301 做轉址,因為權重能完整繼承。
<% Response.Status = "301 Moved Permanently" Response.AddHeader "Location", "https://www.yourdomain.com" %>
<? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: https://www.yourdomain.com" ); ?>
<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>
# 將整個目錄下的內容導向新站對應位置 Redirect permanent / https://www.yourdomain.com/ # 將首頁導向指定檔案 Redirect permanent / https://www.yourdomain.com/404.htm
關鍵在 permanent 這個字。少了它一樣會跳轉,但那屬於 302 暫時性重定向,權重不會移轉。
1. 開啟「網際網路資訊服務管理員」,在要重定向的網頁或目錄上按右鍵。
2. 選擇「重定向到 URL」。
3. 在「重定向到」欄位填入目標網址。
4. 勾選「資源的永久重定向」(這一步最關鍵)。
5. 點擊「確定/套用」。