.htaccess & 403 Forbidden
On this page
The 403 Forbidden Error may show if your
.htaccess
file or the
public_html/
folder is inaccessible due to file permissions.
The 403 Forbidden Error may appear under the following error messages:
- Forbidden. You don't have permission to access this directory on this server.
- Forbidden. You don't have permission to access this resource.
- HTTP Error 403 – Forbidden
- Error 403 – Forbidden
- 403 Forbidden: Request forbidden by administrative rules.
- Access Denied: You don't have permission to access
Common causes
- Incorrect file or directory permissions
- Missing
index.php
,index.html
orindex.htm
page in thepublic_html/
folder - If you use WordPress, faulty WordPress plugins may cause the error
Fix 403 Forbidden Error
Create the public folder
Verify that you have the public directory created:
/var/www/my_domain/public_html/
for Apache./usr/share/nginx/html/
for nginx. Others may be/var/www/html/
.
Create the index page
Navigate to the public directory, i.e.
public_html/
, and check that you an index file:
index.php
index.html
index.htm
Check file and directory permissions
Generally, use the following files and directories permissions:
- 755for directories
- 644for static content (images,
.htaccess
) - 700for dynamic content (PHP files)
Set the correct directory permissions for the public directory, the
public_html/
folder:
cd /var/www/my_domain/
chmod 755 public_html/
Set the correct file permissions for the
.htaccess
file:
cd /var/www/my_domain/public_html/
chmod 644 .htaccess
Check the .htaccess file
Certain directives placed in the
.htaccess
file may cause the 403 Forbidden Error.
Empty the entire
.htaccess
file to determine if the error is caused by the directives. Keep the file using the permissions suggested above (644).
Disable WordPress plugins
Faulty WordPress plugins may be the cause for the 403 Forbidden Error.
Disable newly installed plugins or disable plugins one by one until the error is triggered again.