301 Moved Permanently

HTTP 301 Moved Permanently 重定向回應碼代表所請求的資源已經被明確移動到 Location 標頭所指示的URL。瀏覽器會重新導向到此頁面,而搜尋引擎則會更新該資源的連結。 (in 'SEO-speak', it is said that the 'link-juice' is sent to the new URL)

儘管規範要求當執行重新導向時,請求方法 (以及主體) 不應該被更動,但並非所有的用戶代理皆遵循它 -- 你依然可以找到具有此類漏洞的軟體。因此,推薦只使用 301 回應碼作為 GETHEAD 方法的回應, 另外使用 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

規範

Specification Title
RFC 7231, section 6.4.2: 301 Redirect Permanently Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

瀏覽器相容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
301Chrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

參見