Hello,
I have created multiple websites through the Magento back-end of my site with no problems. They are:
Retails>Retail Store>Retail Default (code:retail_default)
Wholesale>Wholesale Store> Wholesale Default(code: wholesale_default)
I have however trouble finding out how to set up my multi-store site using sub-directory method.
The store is being developed on a test site evidently, but I want to set up the url so that the retail site will eventually be accessed through the main domain, i.e. http://www.mydomain.com, and the wholesale site be accessed through a sub-directory, i.e http://www.mydomain.com/wholesale.
I have read so many articles about how to set this up by copying the index.php and the .htaccess to the wholesale sub-directotory and making certain modifications to these, but none has worked for my Magneto 1.7.0.2 site!
I would really appreciate it if you could advise me how to set this up please.
I copy here below what I read in: http://blog.magikcommerce.com/how-to…ento-commerce/, which sounds graet but doesn’t seem to be for Magento 1.7.0.2!
"
How To Setup Magento Powered Store using Sub-directory Method
Suppose you want to setup multiple stores under different sub-directories on the same server then you should follow this method. In this method you will have one primary domain and you will call you additional store by calling the sub-directory in the URL. i.e.
Mainstore.com/store1
Maninstore.com/store2
Follow the steps given below:
Login to your site via SSH, and create a subdirectory where your second store will be:
cd public_html
mkdir mystore1/
cd mystore1/
Copy the index.php and .htaccess file from the directory where Magento is installed, which would be in our root web directory:
1
cp ../public_html/index.php ../public_html/.htaccess
Open up the index.php file that we just copied over and replace the following line of code:
1
$mageFilename = ‘app/Mage.php’;
with the following:
1
$mageFilename = ‘../public_html/app/Mage.php’;
With the index.php file still open, replace the following line of code:
1
Mage::run();
with the following:
1
Mage::run(‘mystore1’, ‘website’);
"
Any ideas, tutorials, links…
Thank you.
Susan
10 answers
Hi,
Thanks for the link. Great tutorial, however the index.php is changed a bit in the new version of Magento, so Steps 11 to 13 have to be rewritten. These 3 steps copied from the tutorial are:
11.Change $compilerConfig = ‘includes/config.php’; to $compilerConfig = ‘../includes/config.php’;
12.Change $mageFilename = ‘app/Mage.php’; to $mageFilename = ‘../app/Mage.php’;
13.Change Mage::run(); to Mage::run(‘second’,’website’) {Please refer Step 5};
In index.php, however, we now have the following corresponding lines:
define(‘MAGENTO_ROOT’, getcwd());
$compilerConfig = MAGENTO_ROOT . ‘/includes/config.php’;
and
$mageFilename = MAGENTO_ROOT . ‘/app/Mage.php’;
and
/* Store or website code */
$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’;
Mage::run($mageRunCode, $mageRunType);
I am not sure to apply the modifications to the above lines!
Hi susanp,
in this case I think you just need to notice the line of
PHP Code:
Mage::run($mageRunCode, $mageRunType);
Right before it you can add this code
PHP Code:
$mageRunCode = 'wholesale';
$mageRunType = 'website';
I hope it should work !
In fact, it looks to me as modifications to index.php is no longer required! Is that right?
No, I get:
/home/sueproct/public_html/magento/maromausa_test/wholesale/app/Mage.php was not found
This is because the getcwd() of course gets the current director path!
I have read many more tutorials about this, including a great video: http://www.magentocommerce.com/magento-on-the-fly/multiple-sites/
but none give exact information on this point!
Hi susanp,
You can forget the MAGENTO_ROOT and try with this
PHP Code:
$compilerConfig = '../includes/config.php';
$mageFilename = '../app/Mage.php';
Hi,
Yes, I had already tried this. I get: "app/Mage.php was not found". THis result is evident when you look at the code.
Please view the index.php below:
PHP Code:
<?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.magentocommerce.com for more information.
*
* egory Mage
* @package Mage
* Copyright (c) 2008 Irubin Consulting Inc. DBA Varien ([url]http://www.varien.com[/url])
* @license [url]http://opensource.org/licenses/osl-3.0.php[/url] 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 [URL=http://www.joomlart.com/forums/usertag.php?do=list&action=hash&hash=ccc]#ccc[/URL]">
<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;
}
/**
* Error reporting
*/
error_reporting(E_ALL | E_STRICT);
/**
* Compilation includes configuration file
*/
define('MAGENTO_ROOT', getcwd());
/*$compilerConfig = MAGENTO_ROOT . '/includes/config.php';*/
$compilerConfig = '../includes/config.php';
if (file_exists($compilerConfig)) {
include $compilerConfig;
}
/*$mageFilename = MAGENTO_ROOT . '/app/Mage.php';*/
$mageFilename = '../app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
if (is_dir('downloader')) {
header("Location: downloader");
} else {
echo $mageFilename." was not found";
}
exit;
}
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
require_once $mageFilename;
[URL=http://www.joomlart.com/forums/usertag.php?do=list&action=hash&hash=Varien_Profiler%3A%3Aenable%28%29]#Varien_Profiler::enable()[/URL]
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$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';
$mageRunCode = 'wholesale';
$mageRunType = 'website';
Mage::run($mageRunCode, $mageRunType);
Hi,
Thanks.I turned off php Safe Mode as recommended. I think one has to restart the server before this modification would take effect. I contacted my hosting service which is SiteGround. They didn’t advise me on this matter however and directed me to their paid Technical Support
service. I may use their technical support if I don’t find the answer another way later on.
In any case, I still get Mag.php not found error!
Hi susanp,
It’s strange, I saw nothing wrong with those settings but don’t know why it still does not work π