处理“/index.php”时 Magento nginx 重写或内部重定向循环
Magento nginx rewrite or internal redirection cycle while processing "/index.php"
我是 magento 和 nginx 的新手,正在尝试修复网站上损坏的 links。
在我的 nginx 错误日志中,我有以下内容:
2017/09/11 17:09:00 [错误] 23457#23457: *15 处理“/index.php”时重写或内部重定向周期,客户端:127.0.0.1,服务器:localhost,请求:"GET /index.php HTTP/1.1",主机:"localhost",推荐人:“http://localhost/princess-highway/”
在我的 nginx 默认配置文件中,我有以下内容:
# magento specific nginx config for the frontend
server {
listen 80;
server_name localhost;
root /var/www/html;
# check if Load Balancer handled SSL
set $elb_https "off";
if ($http_x_forwarded_proto = "https") {
set $elb_https "on";
}
add_header X-Whom $hostname;
client_max_body_size 2m;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
# testing found online
# try_files $uri $uri/ /index.php?$query_string;
expires 30d; ## Assume all files are cachable
}
## block access
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 /downloader/ { deny all; }
location /errors/ { deny all; }
location /shell/ { deny all; }
location ~ rss/catalog/(review|notifystock) {
deny all;
}
## disable .htaccess and other hidden files
location /. {
return 404;
}
## block API access on non-admin instances
location /api { deny all; }
## block rss feeds
location /rss { return 404; }
## block test scripts
location ^~ /dev/ { return 403; }
## disable hidden files, git files + composer.json
location ~ /(\.|\.git|composer.json|composer.lock) {
return 404;
}
## allow access
location /var/google/ { allow all; }
#location /admin {
# rewrite ^.* http://localhost/factoryx permanent;
#}
#location /factoryx {
# rewrite ^.* https://ao-admin.ap-southeast-2.staging.factoryx.io/factoryx permanent;
#}
location ~ "^/media/picklists/[a-zA-Z0-9]{32}/$" {
autoindex on;
autoindex_localtime on;
}
## Magento uses a common front handler
location @handler {
rewrite / /index.php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
## Forward paths like /js/index.php/x.js to relevant handler
location ~ .php/ {
rewrite ^(.*.php)/ last;
}
location ~ .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTPS $elb_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; ## See /etc/nginx/fastcgi_params
fastcgi_read_timeout 300;
}
}
我有 link 是这样的:
http://localhost/princess-highway/index.php/contacts
上面的 link 会起作用,但是导航菜单上的实际 link 会带你到这里:
http://localhost/princess-highway/contacts
从 link 中省略 index.php,我将收到 500 bad gateway 错误。
我对此很陌生,如果我可以提供更多信息,请告诉我。
谢谢!
使用答案作为注释,因为我需要格式化
尝试添加位置
location /princess-highway/ {
rewrite /princess-highway/(.*) /princess-highway/index.php/;
}
我是 magento 和 nginx 的新手,正在尝试修复网站上损坏的 links。
在我的 nginx 错误日志中,我有以下内容:
2017/09/11 17:09:00 [错误] 23457#23457: *15 处理“/index.php”时重写或内部重定向周期,客户端:127.0.0.1,服务器:localhost,请求:"GET /index.php HTTP/1.1",主机:"localhost",推荐人:“http://localhost/princess-highway/”
在我的 nginx 默认配置文件中,我有以下内容:
# magento specific nginx config for the frontend
server {
listen 80;
server_name localhost;
root /var/www/html;
# check if Load Balancer handled SSL
set $elb_https "off";
if ($http_x_forwarded_proto = "https") {
set $elb_https "on";
}
add_header X-Whom $hostname;
client_max_body_size 2m;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
# testing found online
# try_files $uri $uri/ /index.php?$query_string;
expires 30d; ## Assume all files are cachable
}
## block access
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 /downloader/ { deny all; }
location /errors/ { deny all; }
location /shell/ { deny all; }
location ~ rss/catalog/(review|notifystock) {
deny all;
}
## disable .htaccess and other hidden files
location /. {
return 404;
}
## block API access on non-admin instances
location /api { deny all; }
## block rss feeds
location /rss { return 404; }
## block test scripts
location ^~ /dev/ { return 403; }
## disable hidden files, git files + composer.json
location ~ /(\.|\.git|composer.json|composer.lock) {
return 404;
}
## allow access
location /var/google/ { allow all; }
#location /admin {
# rewrite ^.* http://localhost/factoryx permanent;
#}
#location /factoryx {
# rewrite ^.* https://ao-admin.ap-southeast-2.staging.factoryx.io/factoryx permanent;
#}
location ~ "^/media/picklists/[a-zA-Z0-9]{32}/$" {
autoindex on;
autoindex_localtime on;
}
## Magento uses a common front handler
location @handler {
rewrite / /index.php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
## Forward paths like /js/index.php/x.js to relevant handler
location ~ .php/ {
rewrite ^(.*.php)/ last;
}
location ~ .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTPS $elb_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; ## See /etc/nginx/fastcgi_params
fastcgi_read_timeout 300;
}
}
我有 link 是这样的: http://localhost/princess-highway/index.php/contacts 上面的 link 会起作用,但是导航菜单上的实际 link 会带你到这里: http://localhost/princess-highway/contacts 从 link 中省略 index.php,我将收到 500 bad gateway 错误。
我对此很陌生,如果我可以提供更多信息,请告诉我。
谢谢!
使用答案作为注释,因为我需要格式化
尝试添加位置
location /princess-highway/ {
rewrite /princess-highway/(.*) /princess-highway/index.php/;
}