I have installed Magento 2.1.3 , After that I reload the page, css and js are not loading so, I remove the pub/static content. Then regenerate the static content, after that I checked css url path http://hostname/pub/static/version1486463895/frontend/Magento/luma/en_US/mage/calendar.css
But, within the pub/ststic folder there's no version1486463895 folder.
Reference:
I follow link to deploy static content, after the attempt to generate specific theme now also has the same issue.
 bin/magento setup:static-content:deploy en_US --theme Magento/luma
Update: My nginx.conf.sample file:
 ## Example configuration:
 # upstream fastcgi_backend {
 # # use tcp connection
 # # server 127.0.0.1:9000;
 # # or socket
 # server unix:/var/run/php5-fpm.sock;
 # }
 # server {
 # listen 80;
 # server_name mage.dev;
 # set $MAGE_ROOT /var/www/magento2;
 # include /vagrant/magento2/nginx.conf.sample;
 # }
 #
 ## Optional override of deployment mode. We recommend you use the
 ## command 'bin/magento deploy:mode:set' to switch modes instead.
 ##
 ## set $MAGE_MODE default; # or production or developer
 ##
 ## If you set MAGE_MODE in server config, you must pass the variable into the
 ## PHP entry point blocks, which are indicated below. You can pass
 ## it in using:
 ##
 ## fastcgi_param MAGE_MODE $MAGE_MODE;
 ##
 ## In production mode, you should uncomment the 'expires' directive in the /static/ location block
 root $MAGE_ROOT;
 index index.php;
 autoindex off;
 charset UTF-8;
 error_page 404 403 = /errors/404.php;
 #add_header "X-UA-Compatible" "IE=Edge";
 # PHP entry point for setup application
 location ~* ^/setup($|/) {
 root $MAGE_ROOT;
 location ~ ^/setup/index.php {
 fastcgi_pass fastcgi_backend;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
 location ~ ^/setup/(?!pub/). {
 deny all;
 }
 location ~ ^/setup/pub/ {
 add_header X-Frame-Options "SAMEORIGIN";
 }
 }
 # PHP entry point for update application
 location ~* ^/update($|/) {
 root $MAGE_ROOT;
 location ~ ^/update/index.php {
 fastcgi_split_path_info ^(/update/index.php)(/.+)$;
 fastcgi_pass fastcgi_backend;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param PATH_INFO $fastcgi_path_info;
 include fastcgi_params;
 }
 # Deny everything but index.php
 location ~ ^/update/(?!pub/). {
 deny all;
 }
 location ~ ^/update/pub/ {
 add_header X-Frame-Options "SAMEORIGIN";
 }
 }
 location / {
 try_files $uri $uri/ /index.php?$args;
 }
 location /pub/ {
 location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
 deny all;
 }
 alias $MAGE_ROOT/pub/;
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /static/ {
 # Uncomment the following line in production mode
 # expires max;
 # Remove signature of the static files that is used to overcome the browser cache
 location ~ ^/static/version {
 rewrite ^/static/(version\d*/)?(.*)$ /static/2ドル last;
 }
 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
 add_header Cache-Control "public";
 add_header X-Frame-Options "SAMEORIGIN";
 expires +1y;
 if (!-f $request_filename) {
 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=2ドル last;
 }
 }
 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
 add_header Cache-Control "no-store";
 add_header X-Frame-Options "SAMEORIGIN";
 expires off;
 if (!-f $request_filename) {
 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=2ドル last;
 }
 }
 if (!-f $request_filename) {
 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=2ドル last;
 }
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /media/ {
 try_files $uri $uri/ /get.php?$args;
 location ~ ^/media/theme_customization/.*\.xml {
 deny all;
 }
 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
 add_header Cache-Control "public";
 add_header X-Frame-Options "SAMEORIGIN";
 expires +1y;
 try_files $uri $uri/ /get.php?$args;
 }
 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
 add_header Cache-Control "no-store";
 add_header X-Frame-Options "SAMEORIGIN";
 expires off;
 try_files $uri $uri/ /get.php?$args;
 }
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /media/customer/ {
 deny all;
 }
 location /media/downloadable/ {
 deny all;
 }
 location /media/import/ {
 deny all;
 }
 # PHP entry point for main application
 location ~ (index|get|static|report|404|503)\.php$ {
 try_files $uri =404;
 fastcgi_pass fastcgi_backend;
 fastcgi_buffers 1024 4k;
 fastcgi_read_timeout 600s;
 fastcgi_connect_timeout 600s;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
 gzip on;
 gzip_disable "msie6";
 gzip_comp_level 6;
 gzip_min_length 1100;
 gzip_buffers 16 8k;
 gzip_proxied any;
 gzip_types
 text/plain
 text/css
 text/js
 text/xml
 text/javascript
 application/javascript
 application/x-javascript
 application/json
 application/xml
 application/xml+rss
 image/svg+xml;
 gzip_vary on;
 # Banned locations (only reached if the earlier PHP entry point regexes don't match)
 location ~* (\.php$|\.htaccess$|\.git) {
 deny all;
 }
After that, I try to remove and deploy the static-content
 rm -rf pub/static/frontend/*
 php bin/magento setup:static-content:deploy
Then I refreash the page:
It shows without css and js:
Reference:
css Path:
I click css url path it goes to a 404 page.
Why does this happen? And how to deploy the static content in Magento 2.1.3?
10 Answers 10
Since you are using nginx server you will find nginx.conf.sample in your magento root dir
Use this updated conf file to run your magento source especially this code.
location /static/ {
 # Uncomment the following line in production mode
 # expires max;
 # Remove signature of the static files that is used to overcome the browser cache
 location ~ ^/static/version {
 rewrite ^/static/(version\d*/)?(.*)$ /static/2ドル last;
 }
 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
 add_header Cache-Control "public";
 add_header X-Frame-Options "SAMEORIGIN";
 expires +1y;
 if (!-f $request_filename) {
 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=2ドル last;
 }
 }
 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
 add_header Cache-Control "no-store";
 add_header X-Frame-Options "SAMEORIGIN";
 expires off;
 if (!-f $request_filename) {
 rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=2ドル last;
 }
 }
 - 
 I used
nginx.conf.samplein magento root, its looks same has your suugestRajkumar Elumalai– Rajkumar Elumalai2017年02月07日 11:36:42 +00:00Commented Feb 7, 2017 at 11:36 - 
 edit your question and add your nginx conf codePriyank– Priyank2017年02月07日 12:06:12 +00:00Commented Feb 7, 2017 at 12:06
 - 
 I update my
nginx.conf.samplefileRajkumar Elumalai– Rajkumar Elumalai2017年02月07日 12:09:25 +00:00Commented Feb 7, 2017 at 12:09 
you have to create .htaccess file in pub/static folder with keep below code,
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>
<IfModule mod_php7.c>
php_flag engine 0
</IfModule>
# To avoid situation when web server automatically adds extension to path
Options -MultiViews
<IfModule mod_rewrite.c>
 RewriteEngine On
 # Remove signature of the static files that is used to overcome the browser cache
 RewriteRule ^version.+?/(.+)$ 1ドル [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-l
 RewriteRule .* ../static.php?resource=0ドル [L]
</IfModule>
############################################
## setting MIME types
# JavaScript
AddType application/javascript js jsonp
AddType application/json json
# CSS
AddType text/css css
# Images and icons
AddType image/x-icon ico
AddType image/gif gif
AddType image/png png
AddType image/jpeg jpg
AddType image/jpeg jpeg
# SVG
AddType image/svg+xml svg
# Fonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf
AddType application/x-font-otf otf
AddType application/x-font-woff woff
AddType application/font-woff2 woff2
# Flash
AddType application/x-shockwave-flash swf
# Archives and exports
AddType application/zip gzip
AddType application/x-gzip gz gzip
AddType application/x-bzip2 bz2
AddType text/csv csv
AddType application/xml xml
<IfModule mod_headers.c>
 <FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$>
 Header append Cache-Control public
 </FilesMatch>
 <FilesMatch .*\.(zip|gz|gzip|bz2|csv|xml)$>
 Header append Cache-Control no-store
 </FilesMatch>
</IfModule>
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
 ExpiresActive On
 # Data
 <FilesMatch \.(zip|gz|gzip|bz2|csv|xml)$>
 ExpiresDefault "access plus 0 seconds"
 </FilesMatch>
 ExpiresByType text/xml "access plus 0 seconds"
 ExpiresByType text/csv "access plus 0 seconds"
 ExpiresByType application/json "access plus 0 seconds"
 ExpiresByType application/zip "access plus 0 seconds"
 ExpiresByType application/x-gzip "access plus 0 seconds"
 ExpiresByType application/x-bzip2 "access plus 0 seconds"
 # CSS, JavaScript
 <FilesMatch \.(css|js)$>
 ExpiresDefault "access plus 1 year"
 </FilesMatch>
 ExpiresByType text/css "access plus 1 year"
 ExpiresByType application/javascript "access plus 1 year"
 # Favicon, images, flash
 <FilesMatch \.(ico|gif|png|jpg|jpeg|swf|svg)$>
 ExpiresDefault "access plus 1 year"
 </FilesMatch>
 ExpiresByType image/gif "access plus 1 year"
 ExpiresByType image/png "access plus 1 year"
 ExpiresByType image/jpg "access plus 1 year"
 ExpiresByType image/jpeg "access plus 1 year"
 ExpiresByType image/svg+xml "access plus 1 year"
 # Fonts
 <FilesMatch \.(eot|ttf|otf|svg|woff|woff2)$>
 ExpiresDefault "access plus 1 year"
 </FilesMatch>
 ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
 ExpiresByType application/x-font-ttf "access plus 1 year"
 ExpiresByType application/x-font-otf "access plus 1 year"
 ExpiresByType application/x-font-woff "access plus 1 year"
 ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>
Run command,
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
Remove var folder content from root.
- 
 Still same issue.Rajkumar Elumalai– Rajkumar Elumalai2017年02月07日 12:22:01 +00:00Commented Feb 7, 2017 at 12:22
 - 
 have you create .htaccess file in pub/static and check its available at right location also check using clear broswer cacheRakesh Jesadiya– Rakesh Jesadiya2017年02月07日 12:27:44 +00:00Commented Feb 7, 2017 at 12:27
 - 
 I checked
.htaccess fileis there in with inpub/statici cleared magento cache and browser cache, still same issue.Rajkumar Elumalai– Rajkumar Elumalai2017年02月07日 12:34:29 +00:00Commented Feb 7, 2017 at 12:34 - 
 i have same version issue exist and keep .htaccess file in pub/static solved my issue.Rakesh Jesadiya– Rakesh Jesadiya2017年02月07日 12:35:00 +00:00Commented Feb 7, 2017 at 12:35
 - 
 why css url path show
pub/static/versionxxxx/frontend//xxx/.cssbut. its createdpub/static/frontend/xxx/xxx/.cssright?Rajkumar Elumalai– Rajkumar Elumalai2017年02月07日 12:36:50 +00:00Commented Feb 7, 2017 at 12:36 
Remove var/generation, var/cache, var/page_cache directories.
Then Run all the command in sequence:
php bin/magento deploy:mode:set developer(set the mode of environment as developer)php bin/magento setup:di:compile(generate all the proxies and dependencies )php bin/magento setup:static-content:deploy(deploy all the static content)php bin/magento cache:clean; php bin/magento cache:flush(clear the cache)
It will resolve the issue.
- 
 Still same issueRajkumar Elumalai– Rajkumar Elumalai2017年02月07日 11:51:09 +00:00Commented Feb 7, 2017 at 11:51
 
take this nginx.conf https://github.com/magento/magento2/blob/develop/nginx.conf.sample#L123
or replace your location /static/ section with the same section in this conf file.
Yes, Partiality fixed this issue. nginx.conf.sample file is the issue
I changed root $MAGE_ROOT; root $MAGE_ROOT/pub; it fixed 
Working nginx.conf.sample file
 ## Example configuration:
 # upstream fastcgi_backend {
 # # use tcp connection
 # # server 127.0.0.1:9000;
 # # or socket
 # server unix:/var/run/php5-fpm.sock;
 # }
 # server {
 # listen 80;
 # server_name mage.dev;
 # set $MAGE_ROOT /var/www/magento2;
 # include /vagrant/magento2/nginx.conf.sample;
 # }
 #
 ## Optional override of deployment mode. We recommend you use the
 ## command 'bin/magento deploy:mode:set' to switch modes instead.
 ##
 ## set $MAGE_MODE default; # or production or developer
 ##
 ## If you set MAGE_MODE in server config, you must pass the variable into the
 ## PHP entry point blocks, which are indicated below. You can pass
 ## it in using:
 ##
 ## fastcgi_param MAGE_MODE $MAGE_MODE;
 ##
 ## In production mode, you should uncomment the 'expires' directive in the /static/ location block
 root $MAGE_ROOT/pub;
 index index.php;
 autoindex off;
 charset UTF-8;
 error_page 404 403 = /errors/404.php;
 #add_header "X-UA-Compatible" "IE=Edge";
 # PHP entry point for setup application
 location ~* ^/setup($|/) {
 root $MAGE_ROOT;
 location ~ ^/setup/index.php {
 fastcgi_pass fastcgi_backend;
 fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
 fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=600";
 fastcgi_read_timeout 600s;
 fastcgi_connect_timeout 600s;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
 location ~ ^/setup/(?!pub/). {
 deny all;
 }
 location ~ ^/setup/pub/ {
 add_header X-Frame-Options "SAMEORIGIN";
 }
 }
 # PHP entry point for update application
 location ~* ^/update($|/) {
 root $MAGE_ROOT;
 location ~ ^/update/index.php {
 fastcgi_split_path_info ^(/update/index.php)(/.+)$;
 fastcgi_pass fastcgi_backend;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param PATH_INFO $fastcgi_path_info;
 include fastcgi_params;
 }
 # Deny everything but index.php
 location ~ ^/update/(?!pub/). {
 deny all;
 }
 location ~ ^/update/pub/ {
 add_header X-Frame-Options "SAMEORIGIN";
 }
 }
 location / {
 try_files $uri $uri/ /index.php$is_args$args;
 }
 location /pub/ {
 location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
 deny all;
 }
 alias $MAGE_ROOT/pub/;
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /static/ {
 # Uncomment the following line in production mode
 # expires max;
 # Remove signature of the static files that is used to overcome the browser cache
 location ~ ^/static/version {
 rewrite ^/static/(version\d*/)?(.*)$ /static/2ドル last;
 }
 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
 add_header Cache-Control "public";
 add_header X-Frame-Options "SAMEORIGIN";
 expires +1y;
 if (!-f $request_filename) {
 rewrite ^/static/?(.*)$ /static.php?resource=1ドル last;
 }
 }
 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
 add_header Cache-Control "no-store";
 add_header X-Frame-Options "SAMEORIGIN";
 expires off;
 if (!-f $request_filename) {
 rewrite ^/static/?(.*)$ /static.php?resource=1ドル last;
 }
 }
 if (!-f $request_filename) {
 rewrite ^/static/?(.*)$ /static.php?resource=1ドル last;
 }
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /media/ {
 try_files $uri $uri/ /get.php$is_args$args;
 location ~ ^/media/theme_customization/.*\.xml {
 deny all;
 }
 location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
 add_header Cache-Control "public";
 add_header X-Frame-Options "SAMEORIGIN";
 expires +1y;
 try_files $uri $uri/ /get.php$is_args$args;
 }
 location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
 add_header Cache-Control "no-store";
 add_header X-Frame-Options "SAMEORIGIN";
 expires off;
 try_files $uri $uri/ /get.php$is_args$args;
 }
 add_header X-Frame-Options "SAMEORIGIN";
 }
 location /media/customer/ {
 deny all;
 }
 location /media/downloadable/ {
 deny all;
 }
 location /media/import/ {
 deny all;
 }
 # PHP entry point for main application
 location ~ (index|get|static|report|404|503)\.php$ {
 try_files $uri =404;
 fastcgi_pass fastcgi_backend;
 fastcgi_buffers 1024 4k;
 fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
 fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=18000";
 fastcgi_read_timeout 600s;
 fastcgi_connect_timeout 600s;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
 gzip on;
 gzip_disable "msie6";
 gzip_comp_level 6;
 gzip_min_length 1100;
 gzip_buffers 16 8k;
 gzip_proxied any;
 gzip_types
 text/plain
 text/css
 text/js
 text/xml
 text/javascript
 application/javascript
 application/x-javascript
 application/json
 application/xml
 application/xml+rss
 image/svg+xml;
 gzip_vary on;
 # Banned locations (only reached if the earlier PHP entry point regexes don't match)
 location ~* (\.php$|\.htaccess$|\.git) {
 deny all;
 }
now calling same css and js url but, its worked fine.
Why? There are any limitation is there in Magento 2.1.3?
To deploy static content in magento 2, used following command.
php bin/magento cache:clean
php bin/magento indexer:reindex
php bin/magento setup:upgrade 
php bin/magento setup:static-content:deploy
 - 
 I tried this way same issue.Rajkumar Elumalai– Rajkumar Elumalai2017年02月07日 10:55:41 +00:00Commented Feb 7, 2017 at 10:55
 - 
 I update my answer, try to run this commands.Dhiren Vasoya– Dhiren Vasoya2017年02月07日 10:57:58 +00:00Commented Feb 7, 2017 at 10:57
 
Try with removing Var folder.
rm -rf var/
rm -rf pub/static/frontend/
php bin/magento setup:static-content:deploy
I hope this will help you :)
This is due to Magento "Signing" the files. Essentially it forces Magento to regenerate the public static files on page reload by adding the current timestamp to the files.
This may have changed due to an upgrade of version so check the following configuration is set to no:
Store -> Configuration -> Developer -> Static Files Settings -> Sign Static Files
Be sure to flush the caches after this has been changed
To deploy content you can run multiple commands at the same time.
rm -rf pub/static/*; rm -rf var/view_preprocessed/*; php -f bin/magento setup:static-content:deploy
I've had the same issue changing from developer mode to production and none of the above have worked.
Note: I'm in developer mode before running these commands. Nginx, PHP7.3, Redis, Magento 2.3.4.
This worked for me:
Run the following in your magento/pub/static/ folder. This deletes everything in the static folder except your hidden .htaccess file.
sudo find . -depth -name .htaccess -prune -o -delete
Run the following in your magento root folder
sudo rm -rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/composer_home/ sudo php bin/magento deploy:mode:set production
Run the following in your magento root folder (be aware that my user and group is www-data, maybe yours are not)
sudo chown -R www-data:www-data /var/www/magento
Explore related questions
See similar questions with these tags.
pub/static, its not there