On my local system I am setting up an project. All setup done and its not showing any error. But its not picking css/js.

I run the following commands but no one making effect to work -

sudo chmod -R 0777 var sudo chmod -R 0777 pub
php bin/magento setup:static-content:deploy
php bin/magento cache:flush
php bin/magento indexer:reindex

As I see the view source its adding versionNumber in url like -


and its showing 404 when I hit the url for respective css/js. And As I am checking respective css/js file to respective location without version1487053472, its available .

I am stuck ryt now, how to fix it. Please do a reply if you have any suggestion.

  • Are you using Apache or nginx? It could be that you are missing the required rewrite rules for signed version files to work. Feb 14 '17 at 6:46
  • core_config_data check for web url
    – Jackson
    Feb 14 '17 at 6:46
  • @DannyNimmo - I am using Apache, are saying about mod_rewrite its showing "Module rewrite already enabled"
    – Atul
    Feb 14 '17 at 7:22
  • 1
    You should check that you have the .htaccess file in the pub/static directory: github.com/magento/magento2/blob/2.1.4/pub/static/.htaccess This will add the rewrite for version URLS. Versions are for cachebusting static assets, you can read about cachebusting here: css-tricks.com/strategies-for-cache-busting-css Feb 14 '17 at 7:46

You need to turn off configuration option from backend.

Stores>Configuration>Advanced>Developer>Sign Static Files select No.

Save Config. Now check frontend version number will not display anymore in URLs.

Moreover you need to check .htaccess file in magento_root/pub/static, if it is not present please copy it from github. https://github.com/magento/magento2/blob/develop/pub/static/.htaccess

  • Admin login page also not picking css. And once I made login below erros come - 3 exception(s): Exception #0 (ReflectionException): Class Magento\Authorization\Model\Acl\Role\GroupFactory does not exist Exception #1 (ReflectionException): Class Magento\Authorization\Model\Acl\Role\GroupFactory does not exist Exception #2 (RuntimeException): Can't create directory /var/www/html/git_projects/csep/var/generation/Magento/Authorization/Model/Acl/Role/.
    – Atul
    Feb 14 '17 at 7:19
  • this works for me - in table 'core_config_data' setted 'dev/static/sign' to 0, then flush the cache using - php bin/magento cache:flush and its works now . Thanks Salma
    – Atul
    Feb 14 '17 at 7:37
  • But still have question - Why its adding version-number ?whats the roll of it ?
    – Atul
    Feb 14 '17 at 7:39
  • 2
    Adding a digital signature to the URL of static files makes it possible for browsers to detect when a newer version of the file is available. If you have enabled browser caching it will help to detect newer version. Feb 14 '17 at 7:52
  • 1
    @ErSarveshVTiwari Please try this - In table 'core_config_data' setted 'dev/static/sign' to 0, then flush the cache using - php bin/magento cache:flush and its works now Jun 1 '18 at 6:56

This should actually not lead to a 404 error - you should check your .htaccess in pub/static/ - did you maybe accidentially delete it?

As Salma Saiyad points out in the other answer's comment, this is a actually feature - to use updated files despite of the browser cache on deploys.

  • thx Alex for clarification............ :)
    – Atul
    Jan 31 '18 at 6:34

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.