我一直在浏览很多关于此的文章,但没有任何帮助!
我已经用 Nginx 在 Redhat 上安装了一个 vanilla magento 实例。基本商店按预期工作,但是当我尝试运行使用子目录“/privatesales”配置的单独网站时。
我的 nginx/conf.d/sitename.conf 包含:
server {
listen 192.168.01; ##changed for security
listen 80;
listen 443 ssl;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_session_timeout 7m;
## Specify your SSL options here
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/vanillamagento.local-access.log;
error_log /var/log/nginx/vanillamagento.local-error.log;
server_name vanilla.domain.com;
root /var/www/vanillamagento/magento;
include conf/vanillamagento_rewrites.conf;
include conf/vanillamagento_security.conf;
# PHP handler
location ~ \.php {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite / /index.php last; }
## Store code is defined in administration > Configuration > Manage Stores
## fastcgi_param MAGE_RUN_CODE default;
## fastcgi_param MAGE_RUN_TYPE store;
# By default, only handle fcgi without caching
include conf/magento_fcgi.conf;
}
# 404s are handled by front controller
location @magefc {
rewrite / /index.php;
}
# Last path match hands to magento or sets global cache-control
location / {
## Maintenance page overrides front controller
index index.html index.php;
try_files $uri $uri/ @magefc;
expires 24h;
}
}
我尝试了以下方法来使其正常工作:
1 - 在 index.php 中添加开关功能
$host = explode(':', $_SERVER['HTTP_HOST']);
switch ($host[0]) {
case 'vanilla.domain.com/privatesales':
$store = 'private';
$type = 'website';
break;
default:
$store = 'base';
$type = 'store';
}
2 - 将以下内容添加到 nginx 配置 (conf/vanillamagento_rewrites.conf) 中,然后将 /privatesales 目录符号链接到 webroot
location ~* \.php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires off;
set $runcode default;
set $runtype store;
if ( $request_uri ~* ^/privatesales) {
set $runcode private;
set $runtype website;
}
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 $runcode;
fastcgi_param MAGE_RUN_TYPE $runtype;
include fastcgi_params;
}
只是运气不佳,并且已经尝试解决此问题 2 天:P。谢谢!