2015-04-16 68 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

相关问题