3

I was trying to rectify some ACL issues in my application I removed the static folder inside the pub and I run di:compile and static-content:deploy. Also, I have given 777 permission to var and generated folders, Now when I open the application in the browser no css and js is loaded, I have seen many similar issues but in my case the css and js files are available but the version folder is not available I mean if I saw the source code the URL's are like

http://ipaddress/magento2/pub/static/version1515489121/adminhtml/Magento/backend/en_US/extjs/resources/css/ext-all.css

But the actual file is like

/var/www/html/magento2/pub/static/adminhtml/Magento/backend/en_US/extjs/resources/css/ext-all.css

As I mentioned in the example the version folder is not showing

I don't understand how the folders are created without the version folder.

2
  • Actually the issue is while removing the static files I should have took the backup for the htaccess file, I missed it. I replace the htaccess file from the repository then its fine.
    – Abel
    Commented Jan 9, 2018 at 12:08
  • But there is no image in the pub/media file.
    – Abel
    Commented Jan 9, 2018 at 12:09

4 Answers 4

1

Here is the simplest solution if showing version name in css/js path

run this query in mysql

INSERT INTO core_config_data (path, value) 
VALUES ('dev/static/sign', 0) 
ON DUPLICATE KEY UPDATE value = 0;

after that clear the config cache

 bin/magento cache:clean config
1
  • This can also be done with the command bin/magento config:set dev/static/sign 0 (community.magento.com/t5/Magento-2-x-Technical-Issues/…). But in my case some folders like extjs were still missing so I also used commands php bin/magento setup:static-content:Deploy -f and php bin/magento cache:flush.
    – baptx
    Commented Jun 15 at 0:21
0

try to the following:

php bin/magento setup:upgrade

then

php bin/magento setup:di:compile

then

php bin/magento setup:static-content:deploy

then

sudo chmod 777 -R var

and check the following apache2 configuration:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

if you find AllowOverride None

Change it to AllowOverride All

Regards,

1
  • I tried your solution and @qazqaz999 both of them bring back the magento placeholder image instead of broken image but not the original one.
    – Abel
    Commented Jan 15, 2018 at 5:18
0

In this case, you had "Sign Static Files" enabled (found in Magento admin > Stores > Configuration > Advanced > Developer > Static Files Settings).

This is enabled so that the browser can detect when a newer version of a static file (CSS/JS/HTML) is available for use. This is enabled preferably when your site is subject already for go-live.

When you're in production mode (you can check this through php bin/magento deploy:mode:show) and this is enabled, you can't afford to lose the .htaccess file inside the /pub/static folder. The .htaccess file routes the request for the static files' towards /pub/static.php. And this file will load the static files.

1
  • I tried your solution and @Mohamed Elkashef both of them bring back the magento placeholder image instead of broken image but not the original one.
    – Abel
    Commented Jan 15, 2018 at 5:18
0

I fixed the 404 errors on the CSS / JavaScript files with the command bin/magento config:set dev/static/sign 0 (https://community.magento.com/t5/Magento-2-x-Technical-Issues/CSS-Not-loading-Unable-to-disable-static-files-sign/td-p/433685).

But in my case some folders like extjs were still missing so I also used commands php bin/magento setup:static-content:Deploy -f and php bin/magento cache:flush (maybe not all these commands / parameters are necessary).

Related answers:

Static files version folders not found hence design collapsed and getting 404 for all css and js

Magento2: Wrong path of static contents

For the global 404 error, see this answer:

404 Not Found after fresh Magento 2.4.2 installation

Your Answer

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

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