Have you ever lead to a page saying 403 forbidden error while navigating through the webpages? What is this error and why does it displays? We will see why 403 errors occur and how can we troubleshoot this error. There can be many various reasons behind this error.
What is a 403 Forbidden error
The 403 is an http status code. It is provided by the web server to a client as a response to the client’s request. This error says that the server could understand the request from the client, but it refuses to proceed with further actions with the request. It is often displayed when the server is configured to deny the client’s request for some reason.
This error can be because of the permission issues also. Improper permission configuration to the directories and files may lead to a 403 error.
The causes behind 403 error page
If the URL you’ve entered is correct, then it can be any of the following three reasons.
1) No index page
2) Empty html directory
3) Poor permission configuration or ownership issues.
The above listed are the most common reasons of 403 forbidden error.
How to troubleshoot 403 Forbidden error
Now we are going to see how to troubleshoot the 403 error. Please go through the steps below. If your website is hosted on a shared server, you may not have the permission to all the steps below. But there are still a few things you can try. Please contact support if the error is still visible.
1) As in most website error cases, the first step to troubleshoot this error is to check the URL you’ve entered. Double check the URL to confirm there are no errors and you’ve entered an exact file location and not just a directory. If you’ve entered the directory, the URL will call the entire contents of the particular directory. This case is called directory browsing. Most of the websites will be configured to disallow directory browsing, which may return a 403 Forbidden error. Suppose the path of the index.html page is your web root >> dir1 >> index.html. You need to enter the URL as http://domain.tld/dir1/index.html and not as http://domain.tld/dir1/ as this may lead to a 403 Forbidden error.
In this case, you can enable the directory browsing in the web server. You can also try to clear the browser cache and cookies because it may fix the error sometimes.
How to disable Directory Browsing?
Let’s see how to disable the directory browsing. It can be performed in two ways.
1) With the cPanel interface
2) With .htaccess file
With cPanel interface
Please follow the below steps to disable directory browsing from cPanel.
1) Login to cPanel (http://mydomain.tld:2083). You can login to cPanel from your portal at intelhost.net if you own a shared hosting account.
2) Go to cPanel >> Advanced >> Index Manager.
3) Navigate through the directories and select the desired directory. If you want to select the entire domain, please go up one level and select the domain.
4) From the options, there, select “Standard Indexing”.
5) Save the changes.
To enable directory browsing, please select the “No Indexing” and save the changes.
With the .htaccess file
You can disable the directory indexing with the help of .htaccess file also. You can do this by SSH or with cPanel. You can do this by downloading the file, edit it with a text editor and re-uploading it with FTP. In this documentation, we are going to see how to edit the .htaccess file with cPanel. Please keep a renamed copy of the original file so that you can replace the file if any unexpected error occurred.
1) Login to the cPanel
2) Go to File >> File Manager.
3) Navigate to the document root if you are not there already.
4) Right click on the file and click on edit.
5) Add the below line to the bottom of the file.
Options -Indexes
If there are only the default rule set of WordPress in the .htaccess, the new file will look like this.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Options -Indexes
2) Check whether the action needs to be done after you login to the page. As we’ve discussed earlier, this error message will be displayed when you do not have enough permission to perform the desired action (visiting a page here). Some pages will be accessible only if you signed in to your account. Check whether this is the case here.
3) Disable the .htaccess file and then check to see if the issue is still there. The .htaccess file is known as the configuration file that resides inside the Webroot of the website. The misconfigured rules in the .htaccess may cause the 403-error page. Please disable the file and try if it is working. You can disable the .htaccess by renaming it to some other name like. htaccess.bak.
The .htaccess can be renamed from the cPanel interface. As we’ve seen earlier, go to “File Manager”, right click on .htaccess file then rename it. Please remember to put a default .htaccess file if the website is a WordPress powered one. WordPress needs the .htaccess file with default rule set to work. To create such a file, copy the contents from the above snippet excluding the extra last line. i.e., “Options -Indexes”.
If you need any further assistance please contact our support department.