【问题标题】:Magento inner pages 404 Not Found but homepage getting with nginx serverMagento内页404未找到,但主页正在使用nginx服务器
【发布时间】:2015-10-03 22:52:45
【问题描述】:

这是我的主机文件:

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;
 }
}

我已将 Magento 管理面板中的“使用 Web 服务器重写”更改为“是”,以使 Urls SEO 友好(没有 index.php)。重新启动 nginx 后,我已经从管理面板清除了 magento 缓存。 谁能帮我找出 nginx 配置正确或为什么会出现此错误。

【问题讨论】:

    标签: php magento nginx plesk hhvm


    【解决方案1】:

    你可以试试这个配置:

    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 官方指南:https://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

    【讨论】:

      【解决方案2】:

      这条线对我产生了影响。

      location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
      

      【讨论】:

        【解决方案3】:

        我自己解决了这个问题。我正在使用 Plesk,并且有一个添加附加 nginx 指令的选项。我删除了主机文件“/etc/nginx/conf.d/DOMAIN.conf”(https://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento中的个人站点部分。记得正确配置“/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;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-02-12
          • 2016-05-19
          • 1970-01-01
          • 1970-01-01
          • 2014-01-22
          • 1970-01-01
          • 2020-01-04
          • 2015-07-21
          相关资源
          最近更新 更多