CREATE A MULTI-STORE SETUP IN MAGENTO

There are essentially 3 sections to edit : Plesk Magento index.php

Plesk

Ideally add your new domain name to your Plesk panel as a domain alias with only Web service selected. (ie disable Synchronize DNS zone with the primary domain / Mail service / Redirect with the HTTP 301 code)  This will ensure that all the settings for your main domain are automatically inherited as are settings for varnish etc.  However, this will mean you need a multi-domain ssl.  If you have separate SSL for each domain then you will need to add the new Domain as a separate domain and copy all the settings fro your 1st domain ie php / nginx and apache.

Magento 

1) configure magento.

In system > manage stores

Add a new website, store and store view for your new site. Remember the code for the website.

2) Create a domain alias for you new domain pointing to your existing domain.


Index.php


3) Add a little logic to index.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
umask(0);
 
if ($_SERVER['HTTP_HOST'] == "newdomain.com" || $_SERVER['HTTP_HOST'] == "www.newdomain.com"){
$_SERVER["MAGE_RUN_CODE"] = "website_code";
$_SERVER["MAGE_RUN_TYPE"] = "website";
}
 
/* 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);