HTTP response codes
Every time we enter a URL or make a request from a browser we’re using theHypertext Transfer Protocol (HTTP). Although this sounds like a really cool name for a sci-fi cop movie it’s actually the process by which we request assets such as CSS, HTML and images from a server. After we’ve sent a request these assets will then give a response like “hey I’m here, let’s go!” (response code HTTP 200 OK). There are many different kinds of HTTP response code, the most familiar perhaps being404 Not Found; web pages can respond with a 404 status but so can any other asset that we request, whether that’s an image or any other kind of asset.
Every HTTP response is categorized under a certain three digit number, so 404 Not Found is a 4XX status code to clarify that it’s a client error and 200 is in the 2XX category to signify that it’s a success message of some kind. We’re interested in the 3XX category of HTTP response, like 301 Moved Permanently or 302 Found, because these are the status codes specifically set aside for redirects. Depending on the method we choose we won’t necessarily need to know about these codes but it’s essential for others.
In our case we’ll use a 301 redirect because some web browsers or proxy servers will cache this type, making the old page inaccessible which, in this instance, is exactly what we want.