Magento2 static/version 资源文件404 NOT FOUND问题

7天成为Magento系统架构师,现在开始学习Magento全栈开发!

《Magento2.X企业级开发实战》

Magento2 static/version 资源文件404 NOT FOUND问题。

例如下面的链接 xxxx.com/static/version1483410588/frontend/……

version1483410588这个文件夹服务器里面压根就找不到。

这个其实也不是问题,是伪静态没配置好。

查看magento2根目录下的nginx.conf.sample文件,里面的配置就可以看出问题所在。

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/(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";
}

想去掉这个数字 在后台设置

Configuration/Developer/Static Files Settings/Sign Static Files/ 设置为NO

新安装的magento2后台错乱运行下面的SQL后清理缓存。

INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', '0', 'dev/static/sign', '0')

好吧,这又是一篇废话文章……

文章来源于互联网:Magento2 static/version 资源文件404 NOT FOUND问题

如无特殊说明或标注,任何个人或组织,复制、转载、采集本站内容请注明:
本文来源于:【Magento中文网】,并添加本文地址链接。
如未按上述操作复制或转载,本站有权追究法律责任。
若本站内容侵犯了原著者的合法权益,可联系我们进行处理。