Open In App
Related Articles

HTTP headers | Location

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
The HTTP Location header is a response header that is used under 2 circumstances to ask a browser to redirect a URL (status code 3xx) or provide information about the location of a newly created resource (status code of 201). Its usage is often confused with another HTTP Header which is HTTP Content-Location header. The main difference between them is that Location gives the URL of the resource where the redirection of the page happens while HTTP Content-Location is used to indicate the URL of a transmitted resource. Syntax:
Location: <url>
Directives: This header accepts a single directive mentioned above and described below:
  • <url>: This directive holds the relative or absolute URL that gives access to a resource.
Examples:
  • These URLs include a scheme/host and conform to scheme-specific syntax and semantics, this is an Absolute URL:
    Location: https://www.geeksforgeeks.org/index.php
  • These URLs don’t include a scheme or a host. It must be combined with the URLs of the original request, Relative URL:
    Location: /blogs/
To check this Location in action go to Inspect Element -> Network check the response header for Location like below, Location is highlighted you can see. Supported Browsers: The browsers are compatible with the HTTP Location header are listed below:
  • Google Chrome
  • Internet Explorer
  • Microsoft Edge
  • Firefox
  • Opera
  • Safari

Last Updated : 07 Nov, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads