Table of contents
Magento is one of the most flexible eCommerce platform available today. However, come along with its popularity, there are so many common errors which Magento users often face.
This post shows you more about the most common error: 403 forbidden
What is 403 Forbidden Error?
403 Error or No Access Permission means that you do not have permission to view requested files or resources.
Why does it happen?
This issue occurs by any of the following reasons:
- Incorrect File Permissions
- “No Indexing” in .htaccess file is improperly used
How to Fix 403 Forbidden error?
In Magento 1
- Check file permissions
First, you will want to check the file permissions that each of your files has set. If a file or folder is set to “777” which is “world” writable for security reasons the 403 error will be displayed to protect your website from hacks. Folders should have the permissions set to “750” or “755” and files should be set to “644”.
If you have SSH Access, you can resolve this easily. Make sure you’re in the root directory of your Magento installation, and then execute the following commands:
find ./ -type f | xargs chmod 644 find ./ -type d | xargs chmod 755 chmod -Rf 777 var chmod -Rf 777 media
- Check “No Index” in .htaccess file
Once you have verified that all the permissions are correct but the issue still persists, you will need to check your .htaccess file. Keep in mind that you can have multiple .htaccess files in your account, so you may need to search / modify .htaccess files other than public_html/.htaccess.
For example, if you have an addon domain located at public_html/addon_domain, you’ll need to check any .htaccess files within that folder as well. If one of the lines in the actual file says “Options All -Indexes” then simply remove “-Indexes” and save the file.
In Magento 2
Find your username with this command:
whoami
Then navigate and check if you have config for this user or create if it doesn’t exist:
cd
- Find your username with this command:
whoami
- Then navigate and check if you have config for this user or create if doesn’t exist:
cd
apache2
touch <username>.conf
Where username is an user name used to run Apache server.
- Add the following configuration (note that this is only for Yosamite):
sudo vi
apache2
<username>.conf
Add the following content:
<Directory "/Users/<username>/Sites/"> AddLanguage en .en LanguagePriority en fr de ForceLanguagePriority Fallback Options FollowSymlinks Indexes MultiViews AllowOverride All Order allow,deny Allow from localhost Require all granted </Directory>
- Add lines in the /etc/apache2/httpd.conf configuration file:
sudo vi
apache2/httpd.conf
Check and uncomment the line:
Include /private/etc/apache2/extra/httpd-userdir.conf
- In the httpd-userdir.conf file ensure to uncomment line:
Include /private/etc/apache2/users/*.conf
- Restart Apache server
sudo /usr/sbin/httpd -k restart
apache2/user/ touch <username>.conf
Where username is an user name used to run Apache server.
Add the following configuration (note that this is only for Yosamite):
sudo vi /etc/apache2/user/<username>.conf
Add the following content:
<Directory "/Users/<username>/Sites/"> AddLanguage en .en LanguagePriority en fr de ForceLanguagePriority Fallback Options FollowSymlinks Indexes MultiViews AllowOverride All Order allow,deny Allow from localhost Require all granted </Directory>
Add lines in the /etc/apache2/httpd.conf configuration file:
sudo vi /etc/apache2/httpd.conf
Check and uncomment the line:
Include /private/etc/apache2/extra/httpd-userdir.conf
In the httpd-userdir.conf file ensure to uncomment line:
Include /private/etc/apache2/users/*.conf
Restart Apache server
sudo
/usr/
sbin/httpd -k restart
Hope this helps!
Further Reading:
The Beginner Guide To Magento 2 File Permissions
Magento 2 Error: One or more indexers are invalid
SEE MORE: