HTTP 回應的代碼含義

當我們在瀏覽網頁的時候,經常會看到諸如 500 錯誤之類的訊息,這些錯誤代碼所代表的含義作為網站的開發人員,應該必須瞭解的。

HTTP 的回應代碼是三位數字,其中第一個數字定義了代碼的類別:

範圍 類別 含義
100~199 訊息 請求被接收,正在處理
200~299 成功 動作被成功接收、理解和接受
300~399 重新導向 必須採取其他動作才能完成請求
400~499 用戶錯誤 請求包含不良語法或無法完成
500~599 伺服器錯誤 伺服器無法處理的請求

其中較常見的 HTTP 回應代碼有:

  • 200: 請求成功
  • 400: 語法錯誤
  • 401: 未經授權
  • 403: 禁止訪問
  • 404: 請求的網頁不存在
  • 500: 伺服器錯誤

較為完整的有:

  1. 1xx: Informational - Request received, continuing process
    - 100 - Continue
    - 101 - Switching Protocols
  2. 2xx: Success - The action was successfully received, understood, and accepted
    - 200 - OK
    - 201 - Created
    - 202 - Accepted
    - 203 - Non-Authoritative Information
    - 204 - No Content
    - 205 - Reset Content
    - 206 - Partial Content
  3. 3xx: Redirection - Further action must be taken in order to complete the request
    - 300 - Multiple Choices
    - 301 - Moved Permanently
    - 302 - Moved Temporarily
    - 303 - See Other
    - 304 - Not Modified
    - 305 - Use Proxy
  4. 4xx: Client Error - The request contains bad syntax or cannot be fulfilled - translation: "you blew it."
    - 400 - Bad Request
    - 401 - Unauthorized
    - 402 - Payment Required
    - 403 - Forbidden
    - 404 - Not Found
    - 405 - Method Not Allowed
    - 406 - Not Acceptable
    - 407 - Proxy Authentication Required
    - 408 - Request Time-out
    - 409 - Conflict
    - 410 - Gone
    - 411 - Length Required
    - 412 - Precondition Failed
    - 413 - Request Entity Too Large
    - 414 - Request-URI Too Large
    - 415 - Unsupported Media Type
  5. 5xx: Server Error - The server failed to fulfill an apparently valid request - translation: "the server blew it."
    - 500 - Internal Server Error
    - 501 - Not Implemented
    - 502 - Bad Gateway
    - 503 - Service Unavailable
    - 504 - Gateway Time-out
    - 505 - HTTP Version not supported
  1. No comments yet.

  1. No trackbacks yet.

return top

%d 位部落客按了讚: