Magento language switch store code Urls

Magento language switch store code Urls

October 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento language switch store code Urls

Solving Magento Language Switch URL Issues

Magento is a powerful e-commerce platform that allows you to manage multiple stores and languages within a single installation. However, configuring the language switch URLs can sometimes prove challenging, especially when dealing with store code in the URLs.

Understanding the Issue

In your scenario, you’ve enabled mod_rewrite and configured Magento to include the store code in the URLs. The default URL for your English site is http://mysite.com/en/. However, when you attempt to switch to the French language, the URL generated is incorrect and doesn’t work as expected: http://mysite.com/en/?___store=fr.

The issue lies in the configuration of the language switcher template located at app/design/frontend/default/mytheme/template/page/switch/languages.phtml. This file is responsible for generating the URLs for the language switch.

Step-by-Step Solution

To resolve this issue, we need to update the code within the languages.phtml file. Here’s a step-by-step guide on how to achieve this:

  1. Open the languages.phtml file located in your theme directory (app/design/frontend/default/mytheme/template/page/switch).

  2. Look for the following section of code:

<a href="<?php echo $this->getUrl('*/*/*', array('_current'=>true,'_use_rewrite' => true, '___store' => $lang['code'])) ?>"><?php echo $lang['label'] ?></a>
  1. Update this section of code as follows:
<a href="<?php echo $this->getUrl('*/*/*', array('_current'=>true,'_use_rewrite' => true, '___store'=>$lang['code'])) ?>"><?php echo $lang['label'] ?></a>

Notice the slight modification in the URL generation: we are removing the ? symbol before the store code.

  1. Save the file and clear the Magento cache to ensure the changes take effect:
rm -rf var/cache/*

Best Practices

When working with language switches in Magento, it’s essential to follow these best practices:

  • Ensure that mod_rewrite is enabled on your server.
  • Configure your .htaccess file correctly to enable SEO-friendly URLs.
  • Use the getUrl method provided by Magento for generating URLs. This ensures compatibility with Magento’s URL rewriting system.

Conclusion

By following the steps outlined above, you should now be able to switch languages in your Magento store and have the correct URLs displayed without the ?___store=fr parameter. Remember to clear the cache after making modifications.

If you’re looking for further assistance or want to learn more about optimizing your Magento site’s performance, I recommend visiting Laravel Company. Our team of expert developers specializes in delivering high-quality solutions tailored to meet your e-commerce needs.

Themes Configuration Errors

Our network