Anees Ahmed Mohammed
Anees Ahmed Mohammed

Reputation: 11

Magento 1.9.x Multi site configuration

I am planning to create Magento 1.9.x Multi site configuration using sub domains and i am unable to find good solution. I have followed all the steps mentioned in (https://www.properhost.com/ and Magento support forums), but didnt find any simple and good solutions or i am unable to understand. Could you please suggest me any guide which will be very clear to create multisite with DNS configration with Sub Domains?

in my case. I have deployed http://m1.psoft.co.in (magento base domain) ap.psoft.co.in(sub domain for Andhra Pradesh and having store Nellore Gudur & Ongole) and tn.psoft.co.in (domain for Tamilnandu with cities Chennai and Puducheri). Please let me know if you need any further details.

Upvotes: 0

Views: 1109

Answers (1)

Mohamed23gharbi
Mohamed23gharbi

Reputation: 1780

have you added subfolder containing index.php and .htaccess for th new website ?

for instance : index.php (this one is magento root index) ... tn/ (subfolder for website index) index.php (this index file should be pointed with the tn website domain) .htaccess

the tn/index.php file should containe something like this:

<?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 [email protected] 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);

you can see this link for more details: https://www.crucialhosting.com/knowledgebase/setup-multiple-magento-stores

Or you can use a second method without creating subdirectories :

Step 1: Point all domains to Magento root directory, i.e. same document root in the webserver (Apache or Nginx) configuration.

Step 2: Configure domain names as base URLs for each website in System Configuration in Magento admin panel.

Step 3: Set store or website for each domain as environment variable in .htaccess or in the webserver configuration.

  • Example with the websites as given in the question: SetEnv MAGE_RUN_TYPE website SetEnvIf Host abc.com MAGE_RUN_CODE=domain1 SetEnvIf Host tn.com MAGE_RUN_CODE=domain2
  • Example with store views instead of websites 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

These configurations check if the domain contains "abc.com" or "xyz.com", which I find useful to also match subdomains or test systems like abc.com.testserver.com or test.abc.com, using the same .htaccess file. If you want exact matching, replace abc.com with ^abc.com$

Step 4: Clear cache and access your domains.

See this ansewer : https://magento.stackexchange.com/questions/32439/magento-1-9-multiple-websites-on-different-domains

Upvotes: 1

Related Questions