What is an HTTP 404 Error

In this article, we’ll go over the HTTP 404 Error.

What is an HTTP Status Code

An HTTP Status Code represents the outcome of an HTTP request. When you (a client) make a question (request) to a server to obtain the information for a given site you will get a response, either representing the information for the site or being displayed an error. No matter the outcomes are usually 2 (or 3-4) that you can experience, there are slightly more things happening under the hood, those are represented by the HTTP Status Codes.

An HTTP Status Code will indicate what happened to your request. You can get Status Code instructing you that the resource (URL) which you requested has been moved to a different page, for example, you open the site

HTTP://mysite

but you get redirected to the site

HTTPS://mysite

This is the standard way to make your site load through HTTPS.

The HTTP Status Code, in this case, would be either a 301 or 302, telling you that a redirect was made.

What is an HTTP Status Code 404

404 is of the 4XX Error codes. Those Codes indicate that there is an error on your end, i.e. the resource which you asked for cannot be found. For example, the other Error Codes – 5XX – will indicate that there’s an error with the server.

If you’re hosted on a server using Apache you are asking for resources (URLs) that are accessed using the file structure. For example, you open the site

cPanel Hosting from WebhostFace

mysite/cats

You will look for the cats folder in the mysite document root. You can check our article on Document Roots here – https://www.webhostface.com/kb/knowledgebase/what-is-my-domains-document-root/

If the cats folder does not exist you will get a 404 error.

The cats resource may not always be a folder. Then, the PHP (usually PHP) script needs to make sure that the resource is handled correctly and a proper response is made. Since Apache will usually look for the cats folder we need to directly instruct it to make the request to a specific PHP script instead, not looking at the file system.

This is done by an htaccess rule making all requests made to the Document Root actually be send to the file. Usually frameworks that depend on routing use this, like Laravel or Symfony. The rule usually looks like:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Summary of HTTP 404 Error

If your host cannot help you get rid of this error – contact us and we will do our best to assist you further. We will make sure your website and online project are up and working all the time.

Get professional web hosting, now with an amazing offer – 40% OFF the regular price. Host your online project or start a new one in a matter of minutes.