![]()
In this article i will provide the overview of multiple website setup process in magento
Step1: To Create a Multi Website Navigate to System-> Manage Stores. Create a Website, Store and Storeview respectively.
Step 2: Once the appropriate base URLs are finalised. The WebServer Needs to be configured for the virtual host entries.
Note:- The Configuration file may vary for different Hosting Environment. For windows server the apache configuration file will be named as httpd.conf. Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries. Reference Link:
https://httpd.apache.org/docs/2.2/vhosts/examples.html An Example Sample Configuration done is shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<VirtualHost *:80>
ServerName demo-ecom.mydons.com
DocumentRoot /var/www/html/ms/qa
ServerAdmin admin@mydons.com
ServerAlias demo-ecom.mydons.com
</VirtualHost>
<VirtualHost *:80>
ServerName demo-deals.mydons.com
DocumentRoot /var/www/html/ms/qa
ServerAdmin admin@mydons.com
ServerAlias demo-deals.mydons.com
</VirtualHost>
|
Restart the Webserver
Step 4: Once the Server Setup is done You can configure the base URLs Navigate to
System-> Configuration. Change the Current Configuration Scope to the Required Website. We need to define the base URL for the Second website which we created in the Manage Stores and the Main Website(default installation).
Step 5 Once the Base URL Configuration is done, the index.php file needs to be edited. Based on the Current URL that hits the Server the appropriate Website should be loaded.
File: index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
switch($_SERVER['HTTP_HOST']) {
case 'demo-ecom.mydons.com':
case 'www.demo-ecom.mydons.com':
$mageRunCode = 'base';
$mageRunType = 'website';
break;
case 'demo-deals.mydons.com':
case 'demo-deals.mydons.com':
$mageRunCode = 'mysecondsite'; //The website code for your second website which you have given in manage stores input
$mageRunType = 'website';
break;
}
Mage::run($mageRunCode, $mageRunType);
|