Magento Forum

   
One back-end, multiple stores on different domains
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Hi Guys,

I know this question has been asked many times before but the information I found did not work for me yet.

I’m trying to find the way to install Magento on domain1 and then have a second store on domain2. But the store on domain 2 uses the Magento system on domain1.

I know it has something to do with the changing of the {{base_url}} on domain1 but what eles??

Does someone have the answer?

Kind regards Joshua

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

This baffled me for a while. Here’s what I did in the end:

1. Set up your websites
2. Sent the base URL in the configuration for each website (i.e. domain1.com, domain2.com)
3. Point all the domains to the same place (i.e. domain1.com is the main URL, domain2.com is just an alias for the same site)
4. In your index.php, replace Mage::run() with:

$host explode(':'$_SERVER['HTTP_HOST']);
switch (
$host[0]{
case 'domain1.com':
case 
'www.domain1.com':
  
$store 'store1';
  break;

case 
'domain2.com':
case 
'www.domain2.com':
  
$store 'store2';
  break;

default:
  
$store 'base';
}

Mage
::run($store);

Note 1: domain1.com and http://www.domain1.com will NOT go to the same store unless you define both in the ‘case’ statement.
Note 2: You do not necessarily need to have a ‘case’ for the default store, as that will be caught by the ‘default’ statement at the bottom.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Hi Dave,

Thanks for your help. But one thing isn’t quite clear to me.

What do you do with the $mageFilename?

Standard it’s:

$mageFilename 'app/Mage.php';

But how can i change it to require a file on a other domain still hosted on the same server?
Something like this?

$mageFilename 'var/www/htdocs/domainname.com/app/Mage.php';

Has it something to do with a open base dir?

Kind Regards,

Joshua

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

I didn’t need to do anything with the filename, as the domains both point to the same place.

In other words, if the root is /var/www/htdocs/domain1.com I have domain2.com as an alias, so it’s root is also /var/www/htdocs/domain1.com
Magento does the rest after that.

What I tried to do originally, is set up using separate roots, and in the main index.php I had:

if (empty($mageFilename)) $mageFilename 'app/Mage.php';

Then in the root of domain2.com I had a separate index.php that just had:

$mageFilename = /path/to/app/Mage.php;
include 
'../domain1.com/index.php';

However, as I recall, this didn’t work 100%, but I can’t remember exactly why.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Ok, so what you are saying is that you don’t have do change the $mageFilename.

Instead of this just change the mage::run(); function?

Joshua

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

If all the domains are aliased (point to the same root folder) then yeah, all you need to do is change the Mage::run() function as per my first post.

The root is still the same, even if the requested domain is different, so there’s no need to change that.

If however you are using different root folders for each domain, then you will need to play with $mageFilename (but I don’t recommend this method).

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Hi Dave,

Just to make sure.

- I have installed Magento on “Domain1”
- “Domain2” is empty
- In the back-end of “Domain1” I have configured 2 different website names, store names and store view names in the store manager.
- In the same back-end under system->configuration I have configured the {{base_url}} in the default to “Domain1”.
- Under Store 1 i have configured the {{base_url}} to point to “Domain1” also.
- Under Store 2 i have configured the {{base_url}} to point to “Domain2”.

Is my configuration so far coorect?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

Yep, that’s all correct. So long as (dare I say it again rasberry) the server roots are the same.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Ok,

And by “the same server roots” your are meaning that both Domain are hosted on 1 server?

For your information i have got a dedicated server running and both domains are running on this server.

I would appreciate if you could just help me through the last steps again. What do i have to do on “Domain2” again? It is still empty.

Thanks in advanced.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

Who are you hosted with? Or more to the point, what control panel are you using?

You’re looking for an option like ‘Domain Alias’ or ‘Domain Pointers’.

If you let me know the control panel, I’ll have a look and see how you do it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

We are using a plesk controll panel for a linux/ apache server.

I know what you mean by Domain alias. How do you what to configure this? In the example of “Domain1” and “Domain2”.

Joshua

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

Ah right, it looks like Plesk is a bit rubbish for aliases.

See if this forum thread helps...?

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuavalentin
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2008-07-02
Hengelo, The Netherlands
 

Hi Dave,

Just wanted to thank you very much for your help so far.

If have got it working now. grin

Joshua

 
Magento Community Magento Community
Magento Community
Magento Community
 
Very Clever Stuff
Sr. Member
 
Avatar
Total Posts:  90
Joined:  2008-05-06
Sheffield, UK
 

No problem, glad you got it sorted!

 
Magento Community Magento Community
Magento Community
Magento Community
 
narayan123
Jr. Member
 
Total Posts:  4
Joined:  2010-03-01
 
Very Clever Stuff - 10 July 2008 01:30 AM

This baffled me for a while. Here’s what I did in the end:

1. Set up your websites
2. Sent the base URL in the configuration for each website (i.e. domain1.com, domain2.com)
3. Point all the domains to the same place (i.e. domain1.com is the main URL, domain2.com is just an alias for the same site)
4. In your index.php, replace Mage::run() with:

$host explode(':'$_SERVER['HTTP_HOST']);
switch (
$host[0]{
case 'domain1.com':
case 
'www.domain1.com':
  
$store 'store1';
  break;

case 
'domain2.com':
case 
'www.domain2.com':
  
$store 'store2';
  break;

default:
  
$store 'base';
}

Mage
::run($store);

Note 1: domain1.com and http://www.domain1.com will NOT go to the same store unless you define both in the ‘case’ statement.
Note 2: You do not necessarily need to have a ‘case’ for the default store, as that will be caught by the ‘default’ statement at the bottom.

Hi Dave,
Thanks for your suggestion. But my problem is something different. I have a domain name where magento is fully installed with database in the same server. I want to set up 4 different store with different domain name in 4 different server and want to control the contents of the four store with my main site admin panel which i mentioned before.
for e.g
suppose,
http://www.example.com is my master magento site with admin panel

and four different store with different domain name are as follows:

http://www.example.co.uk
http://www.example.com.us
http://www.example.in
http://www.example.nl

No i want to control content and all store view, products etc from my main store http://www.example.com for the sites
http://www.example.co.uk
http://www.example.com.us
http://www.example.in
http://www.example.nl

Is It possible in magneto ?
if yes, Please feel pain to reply me.
Any suggestion or hints is highly appreciated.

Thanks
Narayan
Navigators Software Private Limited
(Leading Magento Development Company in India)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top