Magento – Storeview / Change language by URL (Change laguage via URL)

It is a much discussed problem: How do I change the URL using the Store View or language?

You can set up the backend different Store Views, change depending on the drop-down setting in the front end will look and / or language. But it is difficult, when (Google also reasons) would like to use for a Store View a different domain, as for the other view.

So the starting point:

It should www.english.com for the English Store View (“english” be used and

www.deutsch.de for the German store view (“German”).

That, of course registered by both domains and cPanel (o.ä.) auf public_html (o.ä.) be routed, Once we put forward.
The two views are well set up and store in the configuration > Web ist bei Storeview “German” as the base URL www.deutsch.de und bei Storeview “english” is www.english.com deposited (and the other URLs).

Now it goes to the important points:

1. Index.php: Ansich here is the motto

switch($_SERVER['HTTP_HOST']) { 

// Deutsch
case 'www.deutsch.de':
case 'deutsch.de':
$_SERVER["MAGE_RUN_CODE"] = "German";
$_SERVER["MAGE_RUN_TYPE"] = "website";
break;

// English
case 'www.englisch.de':
case 'englisch.de':
$_SERVER["MAGE_RUN_CODE"] = "English";
$_SERVER["MAGE_RUN_TYPE"] = "website";
break;

// Otherwise (default store)
default:
break;
}

The procedure. These lines between

#ini_set('display_errors', 1);

and

umask(0);

insert

This setting now works for the case, that with www. and without www. the URL is called and it is a site, is to change the. But should only be called when no store view website, there is the problem, that

 

// English
case 'www.english.com':
$_SERVER["MAGE_RUN_CODE"] = "english";
$_SERVER["MAGE_RUN_TYPE"] = "storeview";
break;

 

will not work, since it is not possible with Magento, Store Views on the command “storeview” call. Totally illogical but this version is broken:

 

// English
case 'www.english.com':
$_SERVER["MAGE_RUN_CODE"] = "english";
break;

 

It is so easy to let the last line completely gone.

After this was by changing the front end may be in store Views have changed as well, the URL. On the other hand, of course, the comfortable situation, that when you call the www.english.com The English Store View is called directly.

If it still does not work, probably needs a little something in the. be changed htaccess:

RewriteCond %{HTTP_HOST} !^www.english.com$
RewriteCond %{HTTP_HOST} !^english.com$
RewriteCond %{HTTP_HOST} !^www.deutsch.de$
RewriteCond %{HTTP_HOST} !^ German  .de $
RewriteRule ^(.*)$ http://www.deutsch.de/ $ 1 [The,R = 301]

In particular, the requirement, that www.deutsch.de and the German store view, the main- and basic domain is.

Weitere Informationen -auch zu neueren Magento Versionen gibt es in this und in this Contribution.

Used in Magento versions 1.4.1.0, 1.4.1.1 and 1.5

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.

2 comments on “Magento – Storeview / Change language by URL (Change laguage via URL)”

  1. Hallo,

    the reason is a different naming convention in the admin backend and code.

    Admin | Code
    ———————
    Website | Website
    Store | Storegroup
    Store View | Store

    Store is doubly occupied and thus can only be interpreted depending on the context clearly.
    So now specify to the store MAGE_RUN_CODE a view to want to be MAGE_RUN_TYPE “store” be set, as we “in the code are”.
    Fortunately, “store” anyway the default MAGE_RUN_TYPE if he is left blank, why does the example given, even without the will of MAGE_RUN_TYPE.

Leave a Reply

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