Search code examples
magentomagento2

I am getting 404 error for css and js files after I installed magento


I installed magento 2.4.2 on bluehost vps hosting, but I am getting the website as shown in figure 1 I tried every solution I found online but non of them worked for me.

Solutions I tried:

1- changing the permission for pub/static dir.

2- In app/etc/di.xml, find the virtualType name=”developerMaterialization” section and its item called name=”view_preprocessed”. I changed Symlink with Copy in Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink.

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

4- RewriteEngine On, in /pub/static/.htaccess file

5- set sign static files to No (dev/static/sign to 0)

I wish someone can help


Solution

  • Hi @Silverwolf96 and welcome on StackOverflow.

    There are few things you can try/check.

    1.) Check in the page source if the URLs to your files are correct. If not set correctly, set them manually as described in step 2.

    2.) Go to Store > Configuration > General > Web and set under Base URLs & Base URLs (Secure) your URLs for static files - you can set this URL manually and it needs to be set as http://www.example.com/static/

    3.) You can try to remove pub/static/frontend on the server

    4.) Check what happens if you select Magento Luma as the default theme