2

**resources not loading after changing base url** resources not loading after changing base url. i have tried changing base_url for media files.

  • 4
    Possible duplicate of Magento 2 CSS and JavaScript not loading from correct folder – Asish Hira Apr 28 '16 at 8:05
  • my problem is that magento is looking directly in root floder for media and static files. it is not looking in pub/media folder – usama Apr 28 '16 at 8:15
  • 1
    Check the presence of .htaccess file inside pub/static. While Deleting the files under pub/static to get rid of any existing symlinks, we need to be be careful not to delete the .htaccess file. – Suyash Kumar Bharti Jan 9 '17 at 11:37
2

Magento 2.2.2

Apache/2.4.6 (CentOS)

I tried:

rm -rf pub/static/* generated/* var/page_cache/* var/cache/* var/view_preprocessed/*
chown -R apache:apache .*
find . -type d -exec chmod 0770 {} \;
find . -type f -exec chmod 0660 {} \;
php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

Found out the pub/static/.htaccess file was missing. Added it back in and static content showed up.

1

In your magento root directory run the below command..

for windows system: php bin/magento setup:static-content:deploy

For Linux/Ubuntu: bin/magento setup:static-content:deploy

1

I had the same issue in magento 2, Ubuntu 16.04. You can resolve it by running the following command in your magento 2 root directory

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

In case it gives a warning and fails, run the above command forcibly, like,

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

Post this step, you will have to compile magento setup once again. So, run the following command.

sudo php bin/magento setup:di:compile

1

Sometime it is a hosting settings issue - its try to find "static" folder directly in magento root "/" but not in "pub/"

To fast fix it try to make symbol link in magento root directory

$ ln -s pub/static static

0

None of this worked for me. The problem was apache. Needed to set AllowOverride All in the virtualhost due to Magento's many many .htaccess files.

0

Many of the answers here are good, but all are pieces in a puzzle where there are many such pieces... Therefore, you may need to work through several of the answers on this page to solve your issue.

I am using Apache as well and simply found I needed to enable mod-rewrite for the rewrite rules in the htaccess file(s) in the pub directory to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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