Magento 1.9.x多站点配置

时间:2017-03-15 09:56:23

标签: magento magento-1.9

我打算使用子域创建Magento 1.9.x多站点配置,我无法找到好的解决方案。我已经按照(https://www.properhost.com/和Magento支持论坛)中提到的所有步骤进行了操作,但没有找到任何简单而好的解决方案,或者我无法理解。您能否建议我使用子域名进行DNS配置的多站点创建非常明确的指南?

在我的情况下。我已部署http://m1.psoft.co.in (magento base domain)ap.psoft.co.in(Andhra Pradesh的子域名,拥有Nellore Gudur& Ongole商店)和tn.psoft.co.in(Tamilnandu与Chennai和Puducheri等城市的域名)。如果您需要任何进一步的细节,请告诉我。

1 个答案:

答案 0 :(得分:1)

您是否为新网站添加了包含index.php和.htaccess的子文件夹?

例如: index.php(这是magento root index) ... tn /(网站索引的子文件夹)    index.php(此索引文件应与tn网站域对齐)    htaccess的

tn / index.php文件应包含以下内容:

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage
 * @copyright  Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
if (version_compare(phpversion(), '5.2.0', '<')===true) {
        echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
        exit;
    }

    require '../app/bootstrap.php'; // added ../ here because of subfolder

    /**
     * Compilation includes configuration file
     */
    $compilerConfig = 'includes/config.php';
    if (file_exists($compilerConfig)) {
        include $compilerConfig;
    }

    $mageFilename = '../app/Mage.php'; // added ../ here because of subfolder

    if (!file_exists($mageFilename)) {
        if (is_dir('downloader')) {
            header("Location: downloader");
        } else {
            echo $mageFilename." was not found";
        }
        exit;
    }

    require_once $mageFilename;

    #Varien_Profiler::enable();

    if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
        Mage::setIsDeveloperMode(true);
    }

    #ini_set('display_errors', 1);

    umask(0);

    $mageRunCode = 'tn1'; // your website code
    $mageRunType = 'website'; // runType is website

    Mage::run($mageRunCode, $mageRunType);

您可以看到此链接以获取更多详细信息: https://www.crucialhosting.com/knowledgebase/setup-multiple-magento-stores

或者您可以使用第二种方法而不创建子目录

步骤1 :将所有域指向Magento根目录,即Web服务器(Apache或Nginx)配置中的相同文档根目录。

第2步:在Magento管理面板的“系统配置”中为每个网站配置域名作为基本URL。

第3步:在.htaccess或网络服务器配置中将每个域的商店或网站设置为环境变量。

  • 问题中给出的网站示例: SetEnv MAGE_RUN_TYPE website SetEnvIf Host abc.com MAGE_RUN_CODE=domain1 SetEnvIf Host tn.com MAGE_RUN_CODE=domain2
  • 商店视图而非网站 SetEnv MAGE_RUN_TYPE store SetEnvIf Host abc.com MAGE_RUN_CODE=store_code_1 SetEnvIf Host tn.com MAGE_RUN_CODE=store_code_2
  • 的示例

这些配置检查域名是否包含“abc.com”或“xyz.com”,我认为这些域名也可用于匹配子域名或测试系统,如abc.com.testserver.com或test.abc.com,相同的.htaccess文件。如果您想要完全匹配,请将abc.com替换为^ abc.com $

第4步:清除缓存并访问您的域。

请参阅此问题:https://magento.stackexchange.com/questions/32439/magento-1-9-multiple-websites-on-different-domains