HTTP 301 Moved Permanently
重定向回應碼代表所請求的資源已經被明確移動到 Location
標頭所指示的 URL。瀏覽器會重新導向到此頁面,而搜尋引擎則會更新該資源的連結。用 SEO 的話來說,就是連結養分(link-juice)把你送到了新的 URL 去。
儘管規範要求當執行重新導向時,請求方法 (以及主體) 不應該被更動,但並非所有的用戶代理皆遵循它 -- 你依然可以找到具有此類漏洞的軟體。因此,推薦只使用 301
回應碼作為 GET
或 HEAD
方法的回應, 另外使用 308 Permanent Redirect
作為 POST
方法的替代,因為請求方法的更動在此狀態中是被明確禁止的。
狀態
301 Moved Permanently
範例
用戶端請求
GET /index.php HTTP/1.1 Host: www.example.org
伺服端回應
HTTP/1.1 301 Moved Permanently Location: http://www.example.org/index.asp
規範
規範 | 標題 |
---|---|
RFC 7231, section 6.4.2: 301 Moved Permanently | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
瀏覽器相容性
BCD tables only load in the browser
參見
308 Permanent Redirect
302 Found
, 臨時重新導向