2013-08-31 31 views
0

我一直在瀏覽這麼多的文章,但沒有任何幫助!Magento/Nginx - 子目錄多核心

我在Redhat上用Nginx安裝了一個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。謝謝!

+0

您要求的聲音就像是關於某些特定軟件的配置問題。請聯繫該軟件的供應商,以便爲您提供支持選項和/或諮詢專用於該軟件的問答網站(Stackoverflow是關於常見問題中概述的*編程*問題)。 – hakre

+1

這個問題似乎是題外話題,因爲它是關於配置第三方軟件,這裏是Magento。 – hakre

回答

1

終於搞定了!切換後您必須修改網址!將以下內容添加到您的index.php中:

$host = explode("/",$_SERVER['REQUEST_URI']); 

//print_r($host); die(); 
switch ($host[1]) { 
case 'privatesales': 
$_SERVER['REQUEST_URI']=str_replace("/privatesales","",$_SERVER['REQUEST_URI']); 
$mageRunCode = "privatesales"; 
$mageRunType = "store"; 
//$store = 'privatesales'; 
//$type = 'website'; 
break; 

default: 
$mageRunCode = 'default'; 
$mageRunType = 'store'; 
break; 
} 
Mage::run($mageRunCode, $mageRunType);