在Nginx服务器上使用Magento运行多重设置。 我正在看访问日志,可以清楚地看到发生了什么。 像许多PHPnetworking应用程序一样,它在它的URL中使用了index.php,并且设置为从可见的URL中“隐藏”它来保持它的清洁。
shoes.com/正在返回shoes.com/index.php shoes.com/sneakers正在返回shoes.com/sneakers/index.php
但是,如果我试图进一步,我看到Nginx不包括index.php的子目录,因为它是根目录。 注意:Magento基本上需要一个修改后的index.php来存放在子目录中的多重分区。
结帐示例:
shoes.com/checkout/cart/返回shoes.com/index.php/checkout/cart/
而在多目录目录中:
shoes.com/sneakers/checkout/cart/正在返回shoes.com/sneakers/checkout/cart/,当它应该返回shoes.com/sneakers/index.php/checkout/cart/
我想弄清楚如何让它适用于这个子目录index.php规则。 我有3个独立的文件我的Nginxconfiguration; 这是重写文件:
rewrite_log on; location / { index index.php index.html; try_files $uri $uri/ @handler; } location @handler { rewrite / /index.php; } ## force www in the URL if ($host !~* ^www\.) { #rewrite / $scheme://www.$host$request_uri permanent; } ## Forward paths like /js/index.php/x.js to relevant handler location ~ \.php/ { rewrite ^(.*\.php)/ $1 last; } location /media/catalog/ { expires 1y; log_not_found off; access_log off; } location /skin/ { expires 1y; } location /js/ { access_log off; } location ~ \.php$ { ## Execute PHP scripts if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss expires off; ## Do not cache dynamic content #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; #fastcgi_param HTTPS $fastcgi_https; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores #fastcgi_param MAGE_RUN_TYPE store; include fastcgi_params; ## See /etc/nginx/fastcgi_params
其中一部分是Magento相关的,另一个是nginx。 首先是Magento的一部分:你需要确保你已经正确设置了base_link_url来存储视图。 您只需要在运动鞋目录中使用index.php,并使用正确的MAGE_RUN_CODE。
至于nginx,你告诉它将所有虚拟请求传递给根目录index.php,但是/sneakers所有请求都应该被路由到/sneakers/index.php :
location / { rewrite ^/ /index.php; } location /sneakers { rewrite ^/sneakers /sneakers/index.php; }
但这不是你唯一的问题。 当我不在手机上时,我会更新答案。