Magento 2 Versioning – Why Adding version_no in JS and CSS URL

cssmagento2version

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.

Best Answer

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

Related Topic