0

I am using Magento 2.4.2, I've moved from a VPS to dedicated, on the VPS everything was working , but after moving css/js are not loading, already corrected permissions and regenerated static files, do you have any hints on solving this please.

.htaccess exists in home, pub, and var

Already tried

find . -type f -exec chmod 644 {} \; 
find . -type d -exec chmod 755 {} \; 
find ./var -type d -exec chmod 777 {} \; 
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml

and

rm -rf var/*
rm -rf generated/*
rm -rf pub/static/*
php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento indexer:reindex
php bin/magento setup:static-content:deploy -f
asked Jul 30, 2021 at 19:44
3
  • What do you mean exactly by CSS/JS not loading? 404 on storefront for the assets? The html source isn't including these assets? They're not on disk? etc. etc. etc. Also what's your PHP version? Commented Jul 31, 2021 at 8:45
  • this is how the website is loaded snipboard.io/qSpj20.jpg Commented Aug 1, 2021 at 6:27
  • and this is the console errors snipboard.io/qjItfc.jpg snipboard.io/u7YXEW.jpg Commented Aug 1, 2021 at 6:29

2 Answers 2

1

Check your domain and the static content URL in store > configuration. If the domain is mapped on the pub directory then the static URL should not include the pub directory and if it is mapped on root then the static URL should include the pub directory.

e.g with pub https://www.example.com/pub/static/version123456789/*/*

without pub https://www.example.com/static/version123456789/*/*

Also, check ownership of the static directory. e.g www-data:www-data

I hope you'd find this answer useful

Msquare
9,4627 gold badges30 silver badges71 bronze badges
answered Jul 30, 2021 at 21:17
1
  • Thanks for the help, the domain isn't pointing to pub directory, static directory is owned by the cPanel user Commented Jul 30, 2021 at 22:26
0

Open your core_config_data table in phpMyAdmin.

Changing web/secure/use_in_frontend 1 to 0

Run the all Magento Commands.

Note: Before changing the value, It's advisable to take db backup.

answered Jul 31, 2021 at 6:03
1
  • Thanks, but this didn't solve the issue Commented Aug 1, 2021 at 6:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.