Spec-Zone.ru › HTTP

Headers: Location

Location header

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

  • Learn more
  • See full compatibility
>

The HTTP Location response header indicates the URL to redirect a page to. It only provides a meaning when served with a 3XX redirection response or a 201 Created status response.

In redirections, the HTTP method used to make the redirected request to fetch the page pointed to by Location depends on the original method and the kind of redirection:

  • 303 See Other responses always result in a GET request in the redirection.
  • 307 Temporary Redirect and 308 Permanent Redirect use the same method as the initiating request.
  • 301 Moved Permanently and 302 Found should use the same request method as the initiating request, although this is not guaranteed for older user-agents.

All responses with one of the above status codes include a Location header.

In cases of resource creation, it indicates the URL of the newly-created resource so that a client can make a request for it immediately.

Location and Content-Location are different. Content-Location indicates the URL to use to directly access the resource in future when content negotiation occurred. Location is associated with the response, while Content-Location is associated with the representation that was returned.

Header type Response header

Syntax

Location: <url>

Directives

<url>

May be relative to the request URL or an absolute URL.

Examples

Location: /index.html

Specifications

Specification
HTTP Semantics>
# field.location>

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
Location 1 12 1 15 1 18 4 14 1 1.0 4.4 1

See also

  • Content-Location
  • Status responses including a Location header: 201, 301, 302, 303, 307, 308.

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Location

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API