Magento 2 – (2.13) Failed to load resource: the server responded with a status of 404 (Not Found) **Solved

After spending sometime with Magento 2 (2.13) , as I am running Nginx and PHP 7 fpm I was getting a lot of error and after some research I was able to find a solution simply replace location static in given magento 2 nginx configuration file and restart nginx and php fpm server to reflect changes.

location /static/ {
    if ($MAGE_MODE = "production") {
      expires max;
    }

    # Remove signature of the static files that is used to overcome the browser cache
    location ~ ^/static/version {
      rewrite ^/static/(versiond*/)?(.*)$ /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/(versiond*/)?(.*)$ /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/(versiond*/)?(.*)$ /static.php?resource=$2 last;
      }
    }

    if (!-f $request_filename) {
      rewrite ^/static/(versiond*/)?(.*)$ /static.php?resource=$2 last;
    }

    add_header X-Frame-Options "SAMEORIGIN";
  }

 

Leave a Reply

Your email address will not be published. Required fields are marked *