How To Setup Multiple Magento Stores (Subdomain Method)

Web hosting, SEO, etc... related
Post Reply
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

How To Setup Multiple Magento Stores (Subdomain Method)

Post by Nipuna » Mon Oct 03, 2011 5:03 pm

For this method, we'll pretend we own mall.com, and it's setup as a portal that links to the various shops within the mall. Magento will be installed on the mall.com domain, and all of the shops will be in subdomains, e.g.:

Code: Select all

    
shoes.mall.com
Shirts.mall.com
Here's how we would set this up for the shoes subdomain:

1 Login to cPanel for your domain, and click on the Subdomains icon.
For the Subdomain, we'll enter shoes. cPanel will automatically fill in the next field, so remove public_html/ from the Document Root field, leaving us with just shoes. This step isn't required, but for organizational purposes, it makes more sense.
2 Click the Create button.
3 Login to your site via SSH, and go to the directory that we previously set in the Document Root field above when creating our subdomain. In our case, we would do the following:

Code: Select all

cd shoes/
5 Copy the index.php and .htaccess file from the directory where Magento is installed, which would be in our root web directory:

Code: Select all

cp ../public_html/index.php ../public_html/.htaccess .

6
Open up the index.php file that we just copied over and replace the following line of code:

Code: Select all

$mageFilename = 'app/Mage.php';
…with the following:

Code: Select all

$mageFilename = '../public_html/app/Mage.php';
7 With the index.php file still open, look for this line (it's the last line of the file):

Code: Select all

Mage::run($mageRunCode, $mageRunType);
…and right before this, we're going to add the following code:

Code: Select all

$mageRunCode = 'shoes';
$mageRunType = 'website';
8 Lastly, we need to create symbolic links to point to a few directories:

Code: Select all

ln -s ../public_html/app ./app
ln -s ../public_html/errors ./errors
ln -s ../public_html/includes ./includes
ln -s ../public_html/js ./js
ln -s ../public_html/lib ./lib
ln -s ../public_html/media ./media
ln -s ../public_html/skin ./skin
ln -s ../public_html/var ./var

Here is the link to My past post about adding Domains to Magento stores, Which has the other methods

https://robot.lk/viewtopic.php?f=74&t=2813
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Post by Saman » Tue Oct 04, 2011 10:45 am

Nice one.
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Post by Nipuna » Tue Oct 04, 2011 10:46 am

Thanks
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Post by Neo » Tue Oct 04, 2011 10:51 am

Nice one indeed. I'm sure this will be very helpful for someone who's working with Magento.
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

Re: How To Setup Multiple Magento Stores (Subdomain Method)

Post by Nipuna » Tue Oct 04, 2011 10:52 am

Thanks :)
Post Reply

Return to “Web Related”