gpt4 book ai didi

magento - Nginx Magento配置index.php循环错误

转载 作者:行者123 更新时间:2023-12-02 17:14:49 25 4
gpt4 key购买 nike

我尝试在 Nginx 上设置 Magento,但不断收到以下错误

*41 处理“/index.php”时重写或内部重定向循环

我的该域的配置文件如下,我已将我的域替换为 DOMAIN.info

我还注释掉了一些与 SSL 相关的部分,因为我还没有 SSL 设置

任何帮助将不胜感激。

server {
# Listen on port 80 as well as post 443 for SSL connections.
listen 80;
listen 443 default ssl;

server_name DOMAIN.info www.DOMAIN.info;

# Specify path to your SSL certificates.
#ssl_certificate /etc/nginx/certificates/yourcertificate.crt;
#ssl_certificate_key /etc/nginx/certificates/yourcertificate.key;

# Path to the files in which you wish to
# store your access and error logs.
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

# If the site is accessed via yourdomain.com
# automatically redirect to www.yourdomain.com.
if ($host = 'DOMAIN.info' ) {
rewrite ^/(.*)$ http://www.DOMAIN.info/$1permanent;
}

root usr/share/nginx/www;

location / {
index index.html index.php;
try_files $uri $uri/ @handler;
}

# Deny access to specific directories no one
# in particular needs access to anyways.
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; }

# Allow only those who have a login name and password
# to view the export folder. Refer to /etc/nginx/htpassword.
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}

# Deny all attempts to access hidden files
# such as .htaccess, .htpasswd, etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

# This redirect is added so to use Magentos
# common front handler when handling incoming URLs.
location @handler {
rewrite / /index.php;
}

# Forward paths such as /js/index.php/x.js
# to their relevant handler.
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}

# Handle the exectution of .php files.
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires off;
fastcgi_pass 127.0.0.1:9000;
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;
}
}

我的 nginx.conf 文件如下所示

user www-data;
worker_processes 5;
pid /var/run/nginx.pid;



events {
worker_connections 768;
# multi_accept on;
}

http {

##
# SSL Support
##

map $scheme $fastcgi_https {
default off;
https on;
}

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

最佳答案

问题很可能是缺少“/”

root usr/share/nginx/www;

事实上,如果找不到/index.php,您的配置确实会创建无限循环:

location ~ .php$ { 
if (!-e $request_filename) {
rewrite / /index.php last;
}
...

请注意,如果 -e $request_filename 测试失败,对/index.php 的请求将被重定向到/index.php。请求将再次与相同的位置匹配,测试将再次失败等等 - 直到 nginx 会注意到有太多内部重定向并中止请求处理并出现上述错误。

关于magento - Nginx Magento配置index.php循环错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11951816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com