0

I've been working with Magento for a number of years but I've never come across this before. I'm working on a custom theme for a new site - vanilla Magento 2.4.3 Open Source install - and recently after adding some custom CSS and changing the minicart icon, I keep getting 403 errors from resources in the /pub/static directory. I've set the correct permissions, clean cache, flush cache and the page (any page) will load fine once. If I navigate to another page, cart, anything, the next page that loads returns 403's all from the /pub/static directory.

I know it's not my theme - the admin area is behaving the same way. I managed to set the theme back to Luma and the problem persists.

My dev server is a bare metal machine running Ubuntu 20.04 with Apache, MariaDB, Elasticsearch and Redis.

I've only found [this]New Magento 2.4.1 installation with assets only appearing on first page load, when not created yet in static folder other thread with an issue similar but it's not quite the same.

1
  • The 403 must be generating an error log somewhere - check all your logs to try and narrow it down...
    – paj
    Feb 1, 2022 at 8:41

2 Answers 2

0

Try below command once and check site

php bin/magento  maintenance:enable

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy -f

php bin/magento  maintenance:disable
0

I checked my Apache logs and saw several entries like this:

[Tue Feb 01 03:30:10.546946 2022] [core:error] [pid 361308] [client 199.18.157.82:21614] AH00037: Symbolic link not allowed or link target not accessible:

Which reminded me that a recent change requires the document root to be the /pub directory. So, I looked at my vhost configuration and saw my document root was set to /pub and also my configuration was set to /pub as well. As soon as I changed the configuration to apple the options one folder higher, the errors went away. I honestly don't know if this is the right way to fix this problem but it solved the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.