Magento – Multistore: Various shops address via different URLs

Magento is characterized among others by the simple installation of several shops in an installation. So you can more or less as many shops (Websites and / or stores) and in turn create create many store Views. We are a store view controls using a URL, I discussed a few posts (see here).

Since this is actually the second step and I have now again a URL to a particular shop (Website) wanted to send, I write quickly a To-Do, to drive to several stores on the general domain.

Condition is, that the various sites in the backend, Stores and Store Views are created and activated. Normally it controls directly to a website, or. we want to do this as. Should be referred to a store or store view, Please the article from above for help.

Now in order to achieve the various shops of an installation can, will be shown here, how changed the index.php in the root directory Magento needs to be, um von www.domain1.de auf den “Domain1” Come to shop, its Web site name (or. its Code) “domain1” is.

Dasselbe soll auch für www.domain2.de für den Shop “Domain2” fold.

So we open the index.php and add approximately. in line 72 after umask(0); and before the } the following lines:

// Domain 1 (Anm.: This is just an information to the user and has no meaning for the code)

case 'domain1.de':
case ‘www.domain1.de’:
$_SERVER[“MAGE_RUN_CODE”] = “domain1”;
$_SERVER[“MAGE_RUN_TYPE”] = “website”;
break;

// Domain 2

case 'domain2.de':
case ‘www.domain2.de’:
$_SERVER[“MAGE_RUN_CODE”] = “domain2”;
$_SERVER[“MAGE_RUN_TYPE”] = “website”;
break;

// Standard (default store) (Anm.: This is in all other cases, calls to the standard shop)
default:
break;

Well it might work already. You may delete cache. It is important to note the exact spelling of the code of the website. The name of the website is completely irrelevant. Even the United- sensitive enough for error.

It may be necessary, however, nor the .htaccess be changed, if it does not work. Just try it and after the last line: # none FileETag installed for each side of a rewrite rule:

RewriteCond %{HTTP_HOST} !^ . Domain1 . Of $
RewriteCond %{HTTP_HOST} !^www.domain1.de$

RewriteCond %{HTTP_HOST} !^ . Domain2 . Of $
RewriteCond %{HTTP_HOST} !^www.domain2.de$

Now it should work no later than.

Another variant, the version 1.4 to fold (have not tried it myself), is the following:

In the. Htaccess and add this lines:
SetEnvIf Host DOMAIN1.com MAGE_RUN_TYPE=Storeview1
SetEnvIf Host DOMAIN2.com MAGE_RUN_CODE=Storeview2

Used in Magento versions 1.4.1.0 & 1.4.1.1

Supplement of 12.08.2011:

Actually, I already wanted to write longer, But it was done now but only now. Bei Magento 1.5. is written back to the index.php, not only up there, but this (behind unmask(0); and before /* Store or website code */ $mageRunCoe…):

if ($_SERVER[‘HTTP_HOST’] == “domain.de” || $_SERVER[‘HTTP_HOST’] == “www[oder Subdomain].domain.de”){
$_SERVER[“MAGE_RUN_CODE”] = “[Your website code]”;
$_SERVER[“MAGE_RUN_TYPE”] = “website”;
}

This can be repeated as often.

Für weitere Alternativen, bitte auch diesen and diesen Artikel beachten.

Used in Magento Version 1.5.1.0. Ask? Comments? Suggestions? Gladly!

 

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

12 comments on “Magento – Multistore: Various shops address via different URLs”

  1. I despair yet….have been 3 Days on rum taste, it will not work 🙁 Have ne fresh 1.5.1 he installation.
    Could it be an excerpt of the code (index.php & .htaccess) get?

  2. Maybe you should note yet, that the blog system replaces quotation marks. Was just a little desperate, because it simply would not work..

    The double quotes (“) So to simply by a (‘) be replaced. Then we went with me (Magento 1.5.1)

    Thanks for the instructions, really had some forums and thousands of approaches by. This works great! 🙂

  3. Has someone already using the new version 1.7.0.1 tries? or is there already there is another solution? I'm quite a Newbie when it comes to Magento. Thanks for reply Herlichen land…

  4. I am also despair…
    trying to get to another store for a week by index.php and. htaccess. I have created a subdomain for it and just can not get past.
    can someone help me?

  5. Sehr guter Post!
    Ist es auch möglich eine Domain auf einen StoreView festzulegen und nicht nur auf Website bzw. Store Ebene?
    Danke und viele Grüße

  6. Hallo, muss es denn zwingend eine neue URL.
    Ist es mögliche die selbe URL zu benutzen nur das man dahinter ein /grosshandel anhängt und automatisch eine neuer Store zu sehen ist?(multistore)

    Greeting
    Daniel

    1. Mir fiele aktuell nur die Möglichkeit ein, ein Verzeichnis auf dem Server zu erstellen, which “grosshandel” is. In dieser liegt eine .htaccess, die den Besucher dann auf eine Subdomain o.ä. umleitet mit welcher der Shop verknüpft ist. Vielleicht hift dies als Lösungsweg?

Leave a Reply

Your email address will not be published. Required fields are marked *