How to Multiple Websites Magento 1.4
Today im going to expain you how to setup multiple websites in a single Magento installation.
I was getting crazy trying to solve this. Finally I found the solution.
After create the X Websites you need from your Admin section we hace to edit a piece of code.
Note: each Website has one unique Store and one unique Store View.
Note2: use short and easy Websites codes, we will need them now.

Sub Domain Method
In your Index.php file (in the root directory of the Magento installation) you have to look for:
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
Then replace the found code for this new one:
switch($_SERVER['HTTP_HOST']) {
case 'store1.domain.com':
/* store1 is the code you wrote in the admin
when created the website */
Mage::run('store1', 'website');
break;
// domain.com (default store)
default:
Mage::run();
break;
}
Sub Directory Method
Using a Sub Directory means more job.
First of all you need to create as much as directories you wanna have.
Example:
- http://mydomain.com/store1
- http://mydomain.com/store2
So following the example you will create 2 directories in the root of your magento installation.
Now you have to copy & paste the index.php and the .htaccess to those folders.
Once that we need to edit the index.php.
Look for:
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
And replace it for:
Mage::run('store1', 'website');
You need to repeat this step to every folder, to every index.php you created before.
Now check out this screenshot to see how to configure the Website:
Done!
Now you know how to create multiples Websites in one Magento Installation.
Any questions or ideas, post a comment
Related PostsIf you liked How to Multiple Websites Magento 1.4; the posts below might interest you too:
|





April 2, 2010
00:12
Hi,
I am having trouble setting up 2 webstores in magento 1.4.
I have magento installed at mydomain.com/magento. I wish for store1.mydomain.com to point to the default website on magento and for store2.mydomain.com to point to store2 which I have setup on magento admin. I have followed your instructions for subdomains but do not understand how the subdomains redirect to the correct stores?
Sorry, I am completely new to php and Magento.
Any help would be great.
Thanks, James.
April 3, 2010
20:32
Hi James,
Did you set the “Base URL” in your admin panel (under the Web tab)?
Check out the screenshot I posted:
http://php.quicoto.com/wp-content/uploads/2010/03/system-config-website1.jpg
In your case the Base URL should be store1.mydomain.com
Let me know if that help
Regards
April 22, 2010
06:35
hi,
I’m having trouble understanding creating multiple website on a single installation of magento 1.4(the latest)
It seems so simple in magento 1.4 rather than the older version.
I have shop.mysite.com and store1.mysite.com.
My magento installation is in shop.mysite.com.
I want to create another website/store in store1.mysite.com and I have to create it’s own folder. In older version of magento, we have to put .htaccess and index.php in it. In 1.4, should we have to create
the files?
thanks.
April 22, 2010
08:06
Hey bare,
You have to follow the Sub Domain Method part of the post above.
You have to replace those lines in the index.php
Hope that helps.
Regards
May 11, 2010
14:54
Is there a way to search in all the store when you create more then 1?
This is the only problem i’m facing right now…
May 11, 2010
15:13
Hi Wladimir,
I don’t think is posible to search products in diferent stores from 1 store.
So.. Why having more than 1 store when you want to share product listing?
May 11, 2010
15:23
Actually because we run a large print office and each category is also a subdomain so we got one main shop and all the categorys are shops too.
SO if you search we want user to search in alle of our departments…
because meganto doesn’t let us use the rewtite engine as we want to…
that should be the most powerfull way….but there’s now way for that
May 11, 2010
15:21
Actually because we run a large pritn office and each category is also a subdomain so we got one main shop and all the categorys are shops too.
SO if you search we want user to search in alle of our departments…
because meganto doesn’t let us use the rewtite engine as we want to…
that should be the most powerfull way….but there’s now way for that
May 19, 2010
06:55
Hi,
i have magento installed on two sites. Can i have a common shopping cart for them using the multiple store method stated above?
May 19, 2010
08:21
I hope I understood your question.
No, having multiple websites you can not buy from 2 websites in the same shopping cart.
You have to buy the red shoes from the Shoes Store and the white car from the Car Store.
Hope that helps.
Regards
May 19, 2010
08:41
Hi quicoto,
If i setup multiple stores in my magento, then the shopping cart will be same for all the stores, right?
May 19, 2010
08:56
Hi thewhiz,
I just tested in my local Magento now.
Yes, both “stores” (not Websites) share the shopping cart.
So if you add 1 product from Store 1 and you switch to Store 2 you will see that item in your cart
Regards
June 2, 2010
06:00
Hi,
thanks for the tutorial but I still cannot figure it out … I have the main Magento installation in root and want to add second website in subfolder /wholesale.
I copy index.php and .htaccess into the subfolder. Edit index.php and follow your tutorial … however, when I want to access the new store in /wholesale I am getting app/Mage.php error.
If I change the path to ../app/Mage.php I will get the actual store with correct theme but every link goes to 404 … am I missing some crucial htaccess setting? Redirects?
Thanks
Update: I think I got it working by simply adding RewriteBase /wholesale/ into the .htaccess file … will test it now …
June 2, 2010
08:15
Hi Yara,
Are you using magento 1.4 version? I think this does not work in the 1.3 or older.
About the .htaccess I didn’t modify anything.
If you find the solution, please let me know
June 2, 2010
17:13
Hi Quicoto,
I am using 1.4 version …
so far the combined solution of your tutorial and changing the path for mage.php together with Redirect rule in htaccess file works for me … I need to test it more and will let you know …
Thanks
June 7, 2010
11:59
i am using 1.4
i follow the tutorial with the /wholesale directory but is giving me error “app/Mage.php was not found”
quicoto can you tell me if you got it working ?
June 7, 2010
12:45
i found it.
in the index.php you need to change all the folders path to ../paths instead of /paths
I have some problems with the theme but i ll found out
)
June 7, 2010
13:01
Glad you make it
Any problems you find you can post in our Forums.
http://php.quicoto.com/forum/
June 7, 2010
13:41
i have a problem in my /wholesale is not appearing to have any theme.
i tried a few things but still not appear anything!
is there anything i missing?
i want to use the same theme as the main site.
Should i copy anything to the /wholesale subfolder?
June 7, 2010
13:46
I guess “/wholestore” is the subfolder you created as a new Website, right?
No you don’t need to.
I think it’s something with the thing you changed before “../” and “/” relative paths.
I could help you more deeper if I see some code. maybe you can open a new Topic in our forum and paste some code from your index.php
June 7, 2010
13:55
this is the code…
the directory i created is “/wholesale”
if (version_compare(phpversion(), '5.2.0', '<')===true) { echo 'Whoops, it looks like you have an invalid PHP version.Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" rel="nofollow">Find out</a> how to install Magento using PHP-CGI as a work-around.'; exit; } /** * Error reporting */ error_reporting(E_ALL | E_STRICT); /** * Compilation includes configuration file */ $compilerConfig = '../includes/config.php'; if (file_exists($compilerConfig)) { include $compilerConfig; } $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; } $ip = $_SERVER['REMOTE_ADDR']; $allowed = array('213.7.38.247','82.114.34.238'); // if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) { $basePath = dirname($_SERVER['PHP_SELF']); include_once dirname(__FILE__) . '../errors/index.html'; exit; } require_once $mageFilename; #Varien_Profiler::enable(); if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) { Mage::setIsDeveloperMode(true); } #ini_set('display_errors', 1); umask(0); // this will force to load the Website with the code store1 Mage::run('wholesale' , 'website');June 7, 2010
14:07
I think is something with
If you remove the “../” does it work?
June 7, 2010
14:28
nothing change when i do that
June 7, 2010
14:33
here they say to change that to ../
http://inchoo.net/ecommerce/how-to-set-multiple-websites-with-multiple-store-views-in-magento/
June 7, 2010
15:14
Did you changed all the things inside the .htaccess?
In that post you’re linking says something about RewriteBase
Last time I did was everything fine.
Don’t know how to help you, sorry.
June 7, 2010
15:23
the problem was in configuration/web
(wholesale skope) at the top
it was {{unsecure_base_url}}skin/ and i made it http://www.domain.com/skin/
its working now proberly!
June 7, 2010
15:25
Right, also change the Base URL JavaScript and Base URL Media.
Nice catch
June 7, 2010
15:32
that’s why i am going crazy some times with programming
July 23, 2010
09:18
Hey, I followed your tutorial and I’m still getting a problem, when visiting a subfolder, I get to see my other website’s menu as I should, but all the links end me up on a 404-page with the menu of the default website. Also edited the .htaccess but that didn’t change anything …
Can the problem be in the structure I’m using, since this is a subfolder in a subdomain?
store.domain.com => Default store
store.domain.com/store2 => Second store
This isn’t the final set up for domains, just for testing purposes …
July 23, 2010
09:34
Perhaps subdmonain.com/store is not posible.
I didn’t test that far.
The 404 error, like you said, looks like .htaccess issue.
October 7, 2010
19:44
Hi quicoto,
I’ve been spending a couple of hours trying to find a solution for my problem, and I’ve been directed to your page for a solution…
Based on your example above, you’re creating multiple websites by using subdomains, but would one be able to set up multiple websites using different domains.
For instance:
Base Store: base.com
Website 2: basestore2.com
Your help will be much appreciated.
Thanks in Advance!
Failman
October 7, 2010
19:58
Yes of course.
Playing with Sub-Domains or Domains is exacly the same.
You just need to point all your domains to the same directory (root folder).
Let me know if you could make it
Regards
October 9, 2010
08:04
Failman here!,
Thank you quicoto, I finally got it to work. I was having one of those fail moments where I forgot to change the Base URL to the store I was pointing to.
So I had to change the Base URL to match my domain name…. and voila!
Thanks Again!
Failman
October 9, 2010
13:47
I’m glad you got it Failman
Regards
January 5, 2012
18:44
Hi,
I am having a hard time!!
I have used the sub-domain method and created fbstore.books.com.eg and followed the instructions but this is what I get:
a:5:{i:0;s:121:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'books_working.catalog_category_flat_store_10' doesn't exist";i:1;s:5428:"#0 /home/books/public_html/lib/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)January 5, 2012
20:28
The first line shows the error:
Have you created the stores in your backoffice properly ?
January 26, 2012
01:01
Hi
If you get an error like “app/Mage.php was not found”, don’t worry
If you have created some subfolders as described on top, you have also to modify line 45 in each index.php to the right path. For subfolders, it is fine to change it to: “$mageFilename = ‘../app/Mage.php’;”
Look at the “../” that means one directory up.
March 6, 2012
14:54
Hi everybody,
I am redirected here in searching solution to multi domain, multi store setup.
Background info:
Magento 1.62, WAMP server,
magento installation directory : c:\wamp\www\magento6
virtual hosts :
My setup looks like this:
DocumentRoot “c:/wamp/www/”
ServerName localhost:8080
DocumentRoot “c:/wamp/www/”
ServerName mag-dev.local
DocumentRoot “c:/wamp/www/”
ServerName aki.local
DocumentRoot “c:/wamp/www/”
ServerName classi.local
in c:\windows\system32\drivers\etc\hosts
127.0.0.1 mag-dev.local
127.0.0.1 aki.local
127.0.0.1 classi.local
in magento6/.htaccess I added the following lines:
SetEnvIf Host www\.aki\.local MAGE_RUN_CODE=aki_local
SetEnvIf Host www\.aki\.local MAGE_RUN_TYPE=website
SetEnvIf Host ^aki\.local MAGE_RUN_CODE=aki_local
SetEnvIf Host ^aki\.local MAGE_RUN_TYPE=website
SetEnvIf Host www\.classi\.local MAGE_RUN_CODE=classi_local
SetEnvIf Host www\.classi\.local MAGE_RUN_TYPE=website
SetEnvIf Host ^classi\.local MAGE_RUN_CODE=classi_local
SetEnvIf Host ^classi\.local MAGE_RUN_TYPE=website
in magento admin, I created websites
website: aki.local
store : aki.local
storeview: aki.
Store * aki.local Store* aki.local
Name * english Name* german
Code * aki_en Code* aki_de
Status * enabled Status* enabled
likewise setup for classi.local website.
For current configuration scope aki.local in cofiguration/web/unsecure
BASE URL: http://aki.local:8080/magento6/
BASE SKIN URL: http://aki.local:8080/magento6/skin/
BASE MEDIA URL: http://aki.local:8080/magento6/media/
BASE JAVASCRIPT URL : http://aki.local:8080/magento6/js/
likewise setup for classi.local website
I have copied the themes in appropriate places:
magento6/app/design/frontend/default/aki for theme aki
magento6/app/design/frontend/default/classi for theme classi
magento6/skin/frontend/default/aki skin for aki
magento6/skin/frontend/default/classi skin for classi
I have created CMS pages
title: aki-home
URL-key : home
title: classi-home
URL-key : home
title: home page the default website/store
URL-key : home
for aki.local in system/configuration/web/default pages
CMS Home Page: aki-home.
for classi.local in system/configuration/web/default pages
CMS Home Page: classi-home.
MY PROBLEM:
for the default store, the themes are loaded and working well.
for the http://aki.local:8080 or http://classi.local:8080, the themes are not loaded.
I only see the websites without themes.
how do I tell magento to find the themes for aki.local and classi.local? Do I need create some folders for the new websites?
I would appreciate your answers.
March 6, 2012
15:43
strangely, it works now.
April 27, 2012
14:09
yes more topics about this
I have the same issue as multiple people here. I have setup everything but somehow he still doesn’t see the correct js / css / media folders. Getting so crazy about this.
I am trying the subfolder option, changed the index file, changed the secure / unsecure url changed the media js links to be absolute etc etc etc
Anybody who could help me?