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 -
pub/static/version1487053472/frontend/Cloudways/m2-theme/en_US/mage/calendar.css
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.
2 Answers 2
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– Atul2017年02月14日 07:19:08 +00:00Commented Feb 14, 2017 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 SalmaAtul– Atul2017年02月14日 07:37:43 +00:00Commented Feb 14, 2017 at 7:37
- 
 But still have question - Why its adding version-number ?whats the roll of it ?Atul– Atul2017年02月14日 07:39:44 +00:00Commented Feb 14, 2017 at 7:39
- 
 2Adding 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.Salma Saiyad– Salma Saiyad2017年02月14日 07:52:03 +00:00Commented Feb 14, 2017 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 nowSalma Saiyad– Salma Saiyad2018年06月01日 06:56:34 +00:00Commented Jun 1, 2018 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– Atul2018年01月31日 06:34:18 +00:00Commented Jan 31, 2018 at 6:34
core_config_datacheck for web url.htaccessfile in thepub/staticdirectory: 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