aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/status/302
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/http/status/302')
-rw-r--r--files/zh-cn/web/http/status/302/index.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/status/302/index.html b/files/zh-cn/web/http/status/302/index.html
new file mode 100644
index 0000000000..2e56aaa78f
--- /dev/null
+++ b/files/zh-cn/web/http/status/302/index.html
@@ -0,0 +1,49 @@
+---
+title: 302 Found
+slug: Web/HTTP/Status/302
+tags:
+ - HTTP
+ - 状态码
+ - 重定向
+translation_of: Web/HTTP/Status/302
+---
+<div>{{HTTPSidebar}}</div>
+
+<p>HTTP <code><strong>302</strong></code><strong><code> Found</code></strong> 重定向状态码表明请求的资源被暂时的移动到了由{{HTTPHeader("Location")}} 头部指定的 URL 上。浏览器会重定向到这个URL, 但是搜索引擎不会对该资源的链接进行更新 (In SEO-speak, it is said that the link-juice is not sent to the new URL)。</p>
+
+<p>即使规范要求浏览器在重定向时保证请求方法和请求主体不变,但并不是所有的用户代理都会遵循这一点,你依然可以看到有缺陷的软件的存在。所以推荐仅在响应 {{HTTPMethod("GET")}} 或 {{HTTPMethod("HEAD")}} 方法时采用 302 状态码,而在其他时候使用 {{HTTPStatus("307")}} Temporary Redirect 来替代,因为在这些场景下方法变换是明确禁止的。</p>
+
+<p>在确实需要将重定向请求的方法转换为 {{HTTPMethod("GET")}}的场景下,可以使用 {{HTTPStatus("303")}} See Other。例如在使用 {{HTTPMethod("PUT")}} 方法进行文件上传操作时,需要返回确认信息(例如“你已经成功上传了xyz”)而不是上传的资源本身,就可以使用这个状态码。</p>
+
+<h2 id="状态">状态</h2>
+
+<pre class="syntaxbox">302 Found</pre>
+
+<h2 id="标准">标准</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">标准</th>
+ <th scope="col">标题</th>
+ </tr>
+ <tr>
+ <td>{{RFC("7231", "302 Found" , "6.4.3")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("http.status.302")}}</p>
+
+<h2 id="更多可见">更多可见</h2>
+
+<ul>
+ <li>{{HTTPStatus("307")}} <code>Temporary Redirect</code>, the equivalent of this status code, but that never changes the method used.</li>
+ <li>{{HTTPStatus("303")}} <code>See Also</code>, a temporary redirect that changes the method used to {{HTTPMethod("GET")}}.</li>
+ <li>{{HTTPStatus("301")}} <code>Found</code>, the temporary redirect.</li>
+</ul>