Magento语言按钮商店视图(Magento language button store view)

我在荷兰有一个网站。 http://www.domain.com和http://www.domain.com/german的德国国旗按钮。

我用当地语言德语制作了一个名为德语的商店视图。 如何在链接www.domain.com/german上查看此商店视图

I've an website in dutch. http://www.domain.com and an german flag button to http://www.domain.com/german.

i have made an store view called german with a local language german. How do i get to view this store view on the link www.domain.com/german

最满意答案

这样做的方法很少。

1)在URL中启用商店代码。

Magento允许您将商店视图的商店代码添加到URL。 例如,如果您的荷兰商店视图具有代码dutch并且您的德国商店视图具有代码german ,那么Magento将自动加载正确的商店。 domain.com/dutch将加载荷兰语版本, domain.com/german将加载您网站的德语版本。 此解决方案的缺点是即使对于主域也添加了商店代码。

配置设置可在管理面板(又名后台,BO)>系统>配置> Web> URL选项中找到。 在那里,您会找到“将商店代码添加到网址”选项。

2)编辑.htaccess文件。

如果您想避免解决方案的缺点1)您可以修改主.htaccess文件。 添加将搜索/german后缀的条目,并将加载德语商店代码。 这是一个小例子(我不是这方面的专家,但它应该是这样的):

SetEnvIf Host .*domain.com/german.* MAGE_RUN_CODE="german"

你可以玩.htaccess更多。 如果您想了解更多关于.htaccess在网上搜索。

3)修改应用程序的index.php

这与解决方案2)非常相似,但您可以直接在PHP中执行此操作。 找

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

在index.php中行,并用以下内容替换它:

if (!$_SERVER['MAGE_RUN_CODE'] && strpos($_SERVER['HTTP_HOST'], '/german') !== false) { $mageRunCode = 'german'; } else { $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; }

4)向Apache vhost添加新条目。

为域domain.com/german创建一个新的虚拟主机(vhost),并在那里放置SetEnv MAGE_RUN_CODE "german" 。

在我看来,最好的选择是2)。 它是最灵活的,您不必更改任何代码。 对于开发工作站4)也足够了。

请注意,这些只是示例,它们可能无法在第一次拍摄时使用。 我是从记忆中写下来的,现在我无法真正检查它们。 希望这能让您简要了解如何处理您的情况。

There are few ways for doing this.

1) Enable store code in the URL.

Magento allows you to add a store code of your store view to the URL. For instance, if your Dutch store view has a code dutch and your German store view has a code german, then Magento will automatically load a correct store. domain.com/dutch will load a Dutch version and domain.com/german will load the German version of your website. The drawback of this solution is a store code added even for the main domain.

The config setting can be found in Admin Panel (aka Back Office, BO) > System > Configuration > Web > Url Options. There you will find "Add Store Code to URLs" option.

2) Edit .htaccess file.

If you want to avoid the drawback of solution 1) you can modify your main .htaccess file. Add an entry that will search for /german suffix and will load the German store code. Here's a small example (I'm not an expert in this matter, but it should be something like this):

SetEnvIf Host .*domain.com/german.* MAGE_RUN_CODE="german"

You can play around with .htaccess more. Search the web if you want to learn more about .htaccess stuff.

3) Modify index.php of the application

This is very similar to the solution 2), but you do this directly in PHP. Find

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

line in index.php and replace it with something like this:

if (!$_SERVER['MAGE_RUN_CODE'] && strpos($_SERVER['HTTP_HOST'], '/german') !== false) { $mageRunCode = 'german'; } else { $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; }

4) Add a new entry to the Apache vhost.

Create a new virtual host (vhost) for domain domain.com/german and put there SetEnv MAGE_RUN_CODE "german".

In my opinion the best option is the 2). It is the most flexible and you don't have to change any code. For development workstation 4) would be also sufficient.

Please note that these are only examples and they may not work on the first shot. I'm writing this from my memory and I cannot really check them now. Hope this gives you a brief idea how to handle your situation.

Magento语言按钮商店视图(Magento language button store view)

我在荷兰有一个网站。 http://www.domain.com和http://www.domain.com/german的德国国旗按钮。

我用当地语言德语制作了一个名为德语的商店视图。 如何在链接www.domain.com/german上查看此商店视图

I've an website in dutch. http://www.domain.com and an german flag button to http://www.domain.com/german.

i have made an store view called german with a local language german. How do i get to view this store view on the link www.domain.com/german

最满意答案

这样做的方法很少。

1)在URL中启用商店代码。

Magento允许您将商店视图的商店代码添加到URL。 例如,如果您的荷兰商店视图具有代码dutch并且您的德国商店视图具有代码german ,那么Magento将自动加载正确的商店。 domain.com/dutch将加载荷兰语版本, domain.com/german将加载您网站的德语版本。 此解决方案的缺点是即使对于主域也添加了商店代码。

配置设置可在管理面板(又名后台,BO)>系统>配置> Web> URL选项中找到。 在那里,您会找到“将商店代码添加到网址”选项。

2)编辑.htaccess文件。

如果您想避免解决方案的缺点1)您可以修改主.htaccess文件。 添加将搜索/german后缀的条目,并将加载德语商店代码。 这是一个小例子(我不是这方面的专家,但它应该是这样的):

SetEnvIf Host .*domain.com/german.* MAGE_RUN_CODE="german"

你可以玩.htaccess更多。 如果您想了解更多关于.htaccess在网上搜索。

3)修改应用程序的index.php

这与解决方案2)非常相似,但您可以直接在PHP中执行此操作。 找

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

在index.php中行,并用以下内容替换它:

if (!$_SERVER['MAGE_RUN_CODE'] && strpos($_SERVER['HTTP_HOST'], '/german') !== false) { $mageRunCode = 'german'; } else { $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; }

4)向Apache vhost添加新条目。

为域domain.com/german创建一个新的虚拟主机(vhost),并在那里放置SetEnv MAGE_RUN_CODE "german" 。

在我看来,最好的选择是2)。 它是最灵活的,您不必更改任何代码。 对于开发工作站4)也足够了。

请注意,这些只是示例,它们可能无法在第一次拍摄时使用。 我是从记忆中写下来的,现在我无法真正检查它们。 希望这能让您简要了解如何处理您的情况。

There are few ways for doing this.

1) Enable store code in the URL.

Magento allows you to add a store code of your store view to the URL. For instance, if your Dutch store view has a code dutch and your German store view has a code german, then Magento will automatically load a correct store. domain.com/dutch will load a Dutch version and domain.com/german will load the German version of your website. The drawback of this solution is a store code added even for the main domain.

The config setting can be found in Admin Panel (aka Back Office, BO) > System > Configuration > Web > Url Options. There you will find "Add Store Code to URLs" option.

2) Edit .htaccess file.

If you want to avoid the drawback of solution 1) you can modify your main .htaccess file. Add an entry that will search for /german suffix and will load the German store code. Here's a small example (I'm not an expert in this matter, but it should be something like this):

SetEnvIf Host .*domain.com/german.* MAGE_RUN_CODE="german"

You can play around with .htaccess more. Search the web if you want to learn more about .htaccess stuff.

3) Modify index.php of the application

This is very similar to the solution 2), but you do this directly in PHP. Find

$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

line in index.php and replace it with something like this:

if (!$_SERVER['MAGE_RUN_CODE'] && strpos($_SERVER['HTTP_HOST'], '/german') !== false) { $mageRunCode = 'german'; } else { $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; }

4) Add a new entry to the Apache vhost.

Create a new virtual host (vhost) for domain domain.com/german and put there SetEnv MAGE_RUN_CODE "german".

In my opinion the best option is the 2). It is the most flexible and you don't have to change any code. For development workstation 4) would be also sufficient.

Please note that these are only examples and they may not work on the first shot. I'm writing this from my memory and I cannot really check them now. Hope this gives you a brief idea how to handle your situation.