【问题标题】:Nginx 404 error on every page with magento (except front page)使用magento的每个页面上的Nginx 404错误(首页除外)
【发布时间】:2014-06-28 14:02:02
【问题描述】:

我对此感到头疼。 我有 magento 1.8.1 并将其迁移到 nginx 服务器(来自 apache)

主页确实可以工作,但是当我尝试转到其他页面(如类别或产品页面)时,我从 Nginx 收到 404 错误。 我无法解决这个问题。

我已经安装并运行了 php-fpm。

nginx version: nginx/1.1.19

PHP 5.3.10-1ubuntu3.12 (fpm-fcgi) (built: Jun 20 2014 00:40:17)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.

我的nginx.conf

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
##
# Basic Settings
##
server_tokens off;
sendfile on;
keepalive_timeout 5;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log notice;
rewrite_log on;
log_format main ?$remote_addr - $remote_user [$time_local] $request ?
??$status? $body_bytes_sent ?$http_referer? ?
??$http_user_agent? ?$http_x_forwarded_for??;
##
# Gzip Settings
##
    gzip  on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

我的site.conf

server {
    listen 80 default_server;

server_name xxx.stratoserver.net www.xxx.stratoserver.net; # like ServerName in Apache
root /var/www/vhosts/path_to; # document root
autoindex off; # we don’t want users to see files in directories

#ensure sensitive files are not accessible    
location ~ (^/(app/\|includes/\|lib/\|/pkginfo/\|var/\|report/config.xml)\|/\.svn/\|/\.git/\|/.hta.+) {
deny all; }

location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
if ($request_filename ~* ^.*?/([^/]*?)$)
            {
                set $filename $1; 
            }

            if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
                add_header Access-Control-Allow-Origin *;
            }

    }

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
    access_log        off;
    log_not_found     off;
    expires           360d;
}



  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_CODE default;
    fastcgi_param MAGE_RUN_TYPE store;
    include fastcgi_params;
}

}

谁能帮助我让网站的其余部分正常运行。 phpinfo.php 文件确实有效。

【问题讨论】:

    标签: magento nginx php


    【解决方案1】:

    我也有同样的问题。

    使用这样的链接:magento181/index.php/prodct

    替代:magento181/产品

    这是url重写问题..

    【讨论】:

    猜你喜欢
    • 2012-03-30
    • 2017-07-17
    • 2015-10-16
    • 2016-10-14
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多