2015-04-16 69 views
0

我下載了3個商店的magento並試圖將其安裝在本地主機上。Magento。 Nginx的。多個商店。如何將'index.php'添加到網址

  • Ubuntu的14
  • Nginx的
  • Mysql的
  • PHP-FPM

    /app 
    /downloader 
    /includes 
    ... 
    /store1/index.php 
    /store2/index.php 
    

裏面我store1/index.php我把$mageRunCode = 'my_store_code'

當我打開網址http://mysite.local.dev/store1/一切正常打開,但所有鏈接不包含'index.php',沒有它所有的網址不打開。

返回404:

http://mysite.local.dev/store1/some-cms-page.html

開幕還有:

http://mysite.local.dev/store1/index.php/some-cms-page.html

你能告訴我如何做URL重寫添加人指數.php'來我的網站,或請諮詢另一個更清晰的解決方案。

在此先感謝

server { 

    listen 80; 
    server_name local.dev *.local.dev; 
    root /var/www/local.dev/www/$subdomain; 
    set $subdomain ""; 
    if ($host ~* ^([a-z0-9-\.]+)\.local.dev$) { 
     set $subdomain $1; 
    } 
    if ($host ~* ^www.local.dev$) { 
     set $subdomain ""; 
    } 

    location/{ 
     index index.html index.php; ## Allow a static html file to be shown first 
     try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler 
     expires 30d; ## Assume all files are cachable 
    } 

    ## These locations would be hidden by .htaccess normally 
    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; } 

    location /var/export/ { ## Allow admins only to view export folder 
     auth_basic   "Restricted"; ## Message shown in login window 
     auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword 
     autoindex   on; 
    } 

    location /. { ## Disable .htaccess and other hidden files 
     return 404; 
    } 

    location /api { 
     rewrite ^/api/rest /api.php?type=rest last; 
    } 

    location @handler { ## Magento uses a common front handler 
     rewrite//index.php; 
    } 

    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler 
     rewrite ^(.*.php)/ $1 last; 
    } 

    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 unix:/var/run/php5-fpm.sock; 
     fastcgi_read_timeout 600; 
     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 
    } 

} 

根據Emi`s解決方案。

如果我清楚地瞭解你 - 在這裏更新配置:

在我core_store表我有以下(名稱替換):

default - sitename 
default_store1 - store1 
default_store2 - store2 

不安全的網址是:

http://sitename.local.dev/ 
http://sitename.local.dev/store1/ 
http://sitename.local.dev/store2/ 

當我試圖打開sitename.local.dev它試圖打開$ mage_run_code = sitename。那是因爲我得到了404。我認爲預期值應該是默認

store1的url應該是什麼? sitename.local.dev/store1?

upd.1 我明白了你的想法。

當我們有

if ($host ~* ^([a-z0-9-\.]+)\.local.dev$) { 
     set $subdomain $1; 
     set $magento_run_code $1; 
    } 

Magento的開始以$ 1這3域拉特等於值執行。在我的情況下,http://sitename.local.dev - 它是sitename

我改成了

if ($host ~* ^([a-z0-9-\.]+)\.local.dev$) { 
     set $subdomain $1; 
     set $magento_run_code default; 
    } 

現在,它可以很好地用於第一家專賣店。

讓應用解決方案的商店1

根據這個方案,我現在的問題是:

目錄:{magento_root} /商店1/*

mage_run_code:default_store1

網址:http://store1.local.devhttp://sitename.local.dev/store1/ ??????

nginx的配置:據我可以看到它會取決於網址。我應該使用哪個網址和哪個配置?

回答

0

如果您想運行帶有3個不同商店的Magento,爲什麼不使用默認設置? 默認的意思,你設置一些變量在nginx的配置,這取決於你的主機上,你的情況,你可以使用的東西,就像$子域名:

set $magento_run_code ""; #default value 
if ($host ~* ^([a-z0-9-\.]+)\.local.dev$) { 
    set $subdomain $1; 
    set $magento_run_code $1; 
} 
if ($host ~* ^www.local.dev$) { 
    set $subdomain ""; 
    set $magento_run_code ""; 
} 

然後在位置,你將不得不設置:

fastcgi_param MAGE_RUN_CODE $magento_run_code; 

的值必須從管理(系統>管理存儲)來定義,否則Magento的將無法加載該商店。

而且使用的index.php可以從系統>配置>常規網絡>搜索引擎優化

管理員進行調整有關您加載存儲代碼的詳細信息,從index.php中檢查這些行:

$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'; 
+0

更新我的第一篇 – zhartaunik

+0

好吧,你檢查你的安全和安全基礎URL的每家店?這可以從System> Configuration> GENERAL Web> Unsecured進行更改。從左欄中您可以更改當前配置範圍以匹配您要爲其設置基本網址的商店 - 您必須爲每個商店執行此操作。 – Emi

+0

我添加了我當前的nginx配置並寫下了我的不安全的url。 – zhartaunik

相關問題