![由于缺少正斜杠,JS 和 CSS 文件无法加载](https://linux22.com/image/644403/%E7%94%B1%E4%BA%8E%E7%BC%BA%E5%B0%91%E6%AD%A3%E6%96%9C%E6%9D%A0%EF%BC%8CJS%20%E5%92%8C%20CSS%20%E6%96%87%E4%BB%B6%E6%97%A0%E6%B3%95%E5%8A%A0%E8%BD%BD.png)
我的客户已移至新服务器,即 nginx 和 percona 服务器。问题是 URL 末尾的正斜杠被删除了。如图所示:
因此,设计文件(例如 js、css 文件)无法加载,或者导致 magento 404 未找到页面。它是随机发生的。
在数据库上,web/unsecure/base_url 和 web/secure/base_url 都设置为正斜杠http://78.137.115.47.srvlist.ukfast.net/
我猜想 nginx 文件有问题。重写规则可能有误。我尝试了在本网站和 Google 上找到的所有可能方法,但都无济于事。可能是其他原因。您能帮忙吗?
这是该域的 nginx conf 文件
# Uncomment the server definition below should you wish to
# redirect from punkyfish.com to www.punkyfish.com
#server {
# listen 192.168.92.247;
# server_name punkyfish.com;
# #rewrite / $scheme://www.$host$request_uri permanent;
#}
#
# Change this backend name (and the socket pointer)
# as additional virtual hosts are added. This should
# point to the spawn-fcgi wrapper running as the
# appropriate user.
#
upstream punkyfishcombackend {
server unix:/var/run/php-fcgi-punkyfishcom.sock;
}
server {
listen 192.168.92.247:80;
server_name punkyfish.com;
root /var/www/vhosts/punkyfish.com/htdocs;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /. {
return 404;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
include "ssl_offloading.inc";
location ~ .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass punkyfishcombackend;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default;
# fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
答案1
在数据库中,你需要找到http://srvlist.ukfast.net并将其替换为http://srvlist.ukfast.net/ <-- 添加尾部斜杠
需要澄清的是,当您在测试服务器或开发人员域的情况下更改 Magento 所运行的域时,需要更新的域条目将比您在数据库中找到的 2 个多得多,所有域条目末尾都必须有一个斜杠。