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


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

2 Answers 2


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

  • Thanks for the help, the domain isn't pointing to pub directory, static directory is owned by the cPanel user
    – SoCix
    Jul 30, 2021 at 22:26

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.

  • Thanks, but this didn't solve the issue
    – SoCix
    Aug 1, 2021 at 6:37

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.