HTTP code (also known as status code) is used to determine the result of a request or to indicate an error to the client.
The first digit of the status code is used to specify one of five response categories:
Status code response categories | Definitions |
Information (1XX) | This category indicates that the server has received the request and will continue to process it. |
Success (2XX) | This category indicates that the request has been successfully received, understood and accepted. |
Redirection (3XX) | This category indicates that another action must be taken to complete the query. |
HTTP client error (4XX) | This category indicates that the query contains bad syntax or cannot be completed. |
Server / application server error (5XX) | This category indicates a server or application server error in the execution of the request. |
In this article, we will focus on the meaning of 4 HTTP error codes: 404, 403, 501 and 500. We will also give a few pointers on how to solve the problem when they occur.
Prerequisite
Enter the following address in your web browser: https://my.planethoster.com.
HTTP 404 Error
404 errors are generally caused by a missing file or a non-existent page. Check that the file is present on your hosting. You can check via FTP or from the MG Panel’s File Manager (or cPanel’s File Manager, as the case may be).
And do not forget that file names are case-sensitive. So, if a file contains a capital letter, make sure it is also present in the query.
It is also possible that a rewrite rule is causing a problem in “.htaccess”, which will make the resource unavailable. To test this, temporarily rename the “.htaccess” file.
WordPress tip: add the following code to your “.htaccess” file.
# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
If you get 404 errors on all pages of a site, but not on the home page, this indicates a problem with URL rewriting. When this happens, the CMS expects to receive a URL formed in a certain way and receives it in another form.
HTTP 403 Error
403 errors are generally caused by a file right problem. They are often caused by a 0777 right on shared servers and VPS servers using SuPHP.
Files should use right 0644 and folders right 0755. Binary files or files that use a handler other than PHP – Python, SH or Perl, for example – should use 0755 rights.
It is also possible that the 403 error is caused by a rule in an .htaccess file. To validate this, you can rename .htaccess files temporarily from the folder containing the source of the 403 error and go down one folder at a time to determine which .htaccess is causing the problem.
Please note that .htaccess rules affect all child folders where the file is located. It is therefore important to check all parent .htaccess files, right down to the hosting root /home/username_Cpanel.
HTTP 501 Error
501 errors occur when a feature is not supported by the server, or when a ModSecurity rule is triggered.
To determine the exact reason, you can try consulting the Apache error log. If you are using the MG Panel, the Access Logs article describes how to do this. If you are using cPanel, you will find the error log in Metrics :
If you do not get any errors, it is probably ModSecurity being triggered by one of your scripts. To determine whether ModSecurity is causing the problem, you can temporarily disable it. MG Panel users can refer to the article Configuring the Web App Firewall (WAF) and Firewall History, which explains how to disable the web application bastion. If you are using cPanel, you can do this via Security :
However, note that ModSecurity is implemented to add an extra layer of security. So, if you disable it, you reduce the level of protection.
If the error is indeed returned by ModSecurity, you can contact support to determine which rule is being triggered and have it deactivated.
Here is how to disable a mod_security rule in .htaccess:
#Deactivate one rule only SecRuleRemoveById 123456 #Disable ModSecurity completely SecFilterEngine Off SecFilterScanPOST Off
HTTP 500 Error
Our servers are configured to maximize security for you and your data. This is why we have set up servers with SUPHP. If you get a 500 error, we invite you to change the CHMOD of your files, i.e. 755 for folders and 644 for PHP files. You can do this very easily with the FTP software “FileZilla” (available free of charge) or via your cPanel (with the file manager).
Generally speaking, 500 errors are server errors due to server configuration and, in 90 % of cases, the configuration error comes from an .htaccess file.
You can test this by renaming the .htaccess file in the root directory and working your way down to the script.