我正在使用 fastcgi 在 Nginx 上开发多语言 Magento。一切正常,除了我似乎无法像使用 Apache 那样获得 URL。
我想从 url 中删除 index.php。例子:
/es/index.php/category.html 到 /es/category.html
也用英文 /index.php/category.html 到 /category.html
就这样。
附加信息:
我试图在管理中将“使用 Web 服务器重写”设置为yes。这有效,但仅适用于英语,即默认值,但随后我得到西班牙语的 404,除了主页!
如果我在管理中将 "Use Web Server Rewrites" 设置为no,那么除了将 index.php 添加到 URL 之外,一切正常。但是,如果我从 URL 中手动删除 index.php,页面仍然会转到 404。
此外,在 Magento 管理中,我有这样的基本 URL 设置:https : //www.examplesite.com/es/ 和 {{secure_base_url}}../skin/ 等。
我的根目录 /es/ 中有一个文件夹,其中包含 index.php 的副本,如下所示:
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('es');
这是我的 Nginx 配置:
worker_processes  1;
error_log                           /mba/nginx/logs/error.log;
pid                                 /mba/nginx/logs/nginx.pid;
events {
    worker_connections              2048;
}
http {
    include                         mime.types;
    default_type                    application/octet-stream;
    server_names_hash_bucket_size   64;
    open_file_cache                 max=100 inactive=1m; 
    open_file_cache_valid           20s;
    open_file_cache_min_uses        1;
    open_file_cache_errors          on;
    fastcgi_buffers                 256 4k; 
    ignore_invalid_headers          on; 
    client_header_buffer_size       1k;
    client_body_buffer_size         64k;
    large_client_header_buffers     4 8k;
    client_body_timeout             60;
    client_header_timeout           60;
    keepalive_requests              100;    
    keepalive_timeout               300 300;
    keepalive_disable               msie6;
    send_timeout                    60; 
    max_ranges                      1;  
    reset_timedout_connection       on; 
    sendfile        on; 
    sendfile_max_chunk              512k;
    server_tokens                   off; 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request "'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log                      /mba/nginx/logs/access.log  main;
    autoindex off;
    map $scheme $fastcgi_https { ## Detect when HTTPS is used
        default off;
        https on;
    }
    gzip                            on;
    gzip_static                     on;
    gzip_disable                    "MSIE [1-6]\.";
    gzip_vary                       on;
    gzip_comp_level                 2;
    gzip_min_length                 0;
    gzip_proxied                    any;
    gzip_types                      text/plain image/x-icon image/bmp text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    proxy_buffering on;
    #proxy_cache_path               /mba/nginx/proxy levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;
    proxy_buffer_size               4k;
    proxy_buffers                   100 16k;
    proxy_connect_timeout           60;
    proxy_send_timeout              60;
    proxy_read_timeout              60;
    #include                         /mba/nginx/conf.d/*.conf;
    ##
    # SSL Support
    ##
    map $scheme $fastcgi_https {
    default off;
        https on;
    }
server {
    listen                          80;
    #listen                         443 default ssl;
    expires                         max;
    add_header                      Cache-Control public;   
    #ssl_certificate                /openssl/ssl/www_mybelovedangels_com.crt;
    #ssl_certificate_key            /openssl/ssl/www_mybelovedangels_com.key;
    #access_log                     /mba.nginx.1/mba/nginx/logs/access_log;
    root                            /mba.nginx.1/mba/www;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires                         +60d;
    log_not_found                   off;
    } 
location / {
    index index.html index.php;
    try_files $uri $uri/ @handler;
    expires +30d;
    deny    192.168.1.1;
    allow   192.168.1.0/24;
    allow   127.0.0.1;
    allow   2620:100:e000::8001;
    deny    all;
    }
    # 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 en;
        fastcgi_param MAGE_RUN_TYPE store;
        include fastcgi_params;
    }
  }
}
我希望这不是太多信息,但可能需要它。我在网上到处都找不到我找不到的地方,我对如何做到这一点一无所知。
谢谢