Php 找不到Magento内部页面404,但正在使用nginx服务器获取主页
这是我的主机文件:Php 找不到Magento内部页面404,但正在使用nginx服务器获取主页,php,magento,nginx,plesk,hhvm,Php,Magento,Nginx,Plesk,Hhvm,这是我的主机文件: server { root /path/to/root/domain/html; index index.php; server_name servername.de; location / { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location ^~ /(app|includes|lib|media/
server {
root /path/to/root/domain/html;
index index.php;
server_name servername.de;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location ^~ /(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
location /var/export/ { internal; }
location /. { return 404; }
location @handler { rewrite / /index.php; }
location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
location ~* .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
我已经将“使用Web服务器重写”从Magento管理面板更改为“是”,以使URL SEO友好(没有index.php)。在重新启动nginx之后,我已经从管理面板中清除了magento缓存。
有谁能帮我找出nginx配置是否正确,或者为什么会出现这个错误 您可以尝试以下配置:
server {
root /path/to/root/domain/html;
index index.php;
server_name servername.de;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location @handler { rewrite / /index.php; }
location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
location ~* .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
}
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 @handler {
rewrite / /index.php;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
}
此外,对于此问题和相关问题,您可以查看官方Magento指南:您可以尝试此配置:
server {
root /path/to/root/domain/html;
index index.php;
server_name servername.de;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location @handler { rewrite / /index.php; }
location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
location ~* .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
}
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 @handler {
rewrite / /index.php;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
}
此外,对于此问题和相关问题,您可以查看官方Magento指南:我自己解决了此问题。我使用的是Plesk,可以选择添加额外的nginx指令。我删除了主机文件“/etc/nginx/conf.d/DOMAIN.conf”(请记住正确配置“/etc/nginx/nginx.conf”中的各个站点部分),并在Plesk的“附加nginx指令”管理区域中添加了以下代码
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location /. {
return 404;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
fastcgi_pass fastcgi_backend;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
我自己解决了这个问题。我使用的是Plesk,可以选择添加额外的nginx指令。我删除了主机文件“/etc/nginx/conf.d/DOMAIN.conf”(请记住正确配置“/etc/nginx/nginx.conf”中的各个站点部分),并在Plesk的“附加nginx指令”管理区域中添加了以下代码
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location /. {
return 404;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
fastcgi_pass fastcgi_backend;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
这条线对我来说是不同的
location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
这条线对我来说是不同的
location ~* .php/ { rewrite ^(.*.php)/ $1 last; }