![]() For example, this code will return the response status code for the stated URL (“HTTP/1.1 200 OK” in this example).Įcho($headers) What Status Codes Are Returned by a Website? This will work for the same domain and for (most) external domains. If you try to run this JavaScript code to check status codes on an external domain, you will get an “Access-Control-Allow-Origin” error message.Īs an alternative, you can also check the page’s status code via PHP. Note that this code will not work on external domains or subdomains for security reasons. For example, to check a page on Elementive’s site, I’d have to run this code on Elementive’s domain and pass in relative URLs, such as: One note: this code only works if you are checking on the same domain. You can see an implementation of that on this JSFiddle. Using JavaScript, you can get the HTTP status code of a URL via an XMLHttpRequest. Status Codes in JetOctopus Checking HTTP Status Code via JavaScript and PHPĪlong with the tools discussed above, you can also obtain the HTTP status via code. Pay attention to any pages that don’t return a status 200. After running a crawl, you will see a list of all pages contained on your website and their respective status codes. Alternatively, you can use a tool like Screaming Frog or Jet Octopus to check the response status as well. Instead of checking an individual page at a time, you can also check several pages’ response codes at once using tools like HTTPStatus or Knowledge Bull’s. For example, perhaps you load the page as Googlebot in Web Sniffer and see entirely different HTML code than you see when loading the site in a browser-this would be a big problem for SEO and one you’d want to fix immediately. Viewing the Content helps you compare what is returned against what you expected to be returned. To see an example of the content, we can check a URL that returns a status code of 200. However, you will see content for other status codes, such as a status 200. You won’t see this for a redirected page because a server doesn’t return content when a redirect occurs. How to Check HTTP Response Status Codesįinally, Web Sniffer will also show the content of the returned page. With a 301 or 302 status code, browsers and bots will process the redirect to a different URL. If the requested page redirects elsewhere, the HTTP status code returned will be a 301 or 302. Browsers and bots know to handle this type of HTTP status code as an error page. Alternatively, if the requested page is not found, the status code returned will be a 404. ![]() With that status code, browsers and bots know to load the page as usual. As an example, if the page loads successfully in response to a visitor’s request for that page, the website will return a response status code of 200. There are a number of different response status codes that can be returned. Instead, the browser or bot loading the page will see this response status code and will use that information to help load and process the page. You won’t see the HTTP Response Header or the status code displayed on the page itself. The HTTP Response Status Code is returned in the HTTP Response Header, which contains other details about the page. The status code says if the page is operating correctly, is in error, requires authentication, and more. Whenever you load a page or file on a website, the server hosting that website returns a numerical code that indicates the page’s status, called an HTTP Response Status Code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |