Multiple Magento websites with store view codes as language codes

Multiple Magento websites with store view codes as language codes

August 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Multiple Magento websites with store view codes as language codes

Handling Multiple Magento Websites with Common Language Codes

As an experienced Magento developer, I often face complex scenarios involving multiple websites and common language codes. In this post, we’ll explore how to manage such setups without compromising URL aesthetics or functionality.

The Challenge: Unique Store View Codes vs Common Language Codes

When you have multiple websites serving different countries but share some common navigation languages (e.g., English), the traditional approach of using store view codes as language shortcodes breaks down. This is because each store view code must be unique, making it impossible to represent both French in Canada and German in Belgium with a single fr or de code.

A Workaround: Prefixing Website Codes

One possible solution is prefixing the website name to the store view codes:

  • For Canada (English and French): site1_en, site1_fr
  • For Belgium (French, Dutch, German): site2_fr, site2_nl, site2_de

However, this approach results in ugly URLs like site1.ca/site1_fr instead of the cleaner-looking site1.ca/fr.

The Mod_Rewrite Magic: Cleaning Up URLs

To solve this issue, we can leverage mod_rewrite rules and Magento’s configuration settings. Here are the steps:

  1. Configure Magento to add store codes to URLs: In your admin panel, navigate to Stores > Configuration > General > Web. Set “Add Store Code to URLs” to “Yes”.

  2. Create a mod_rewrite rule: Open your .htaccess file in the root directory of your Magento installation. Add the following rule at the bottom:

RewriteRule ^([a-zA-Z]{2})/(.*)$ $1.$2 [NC,L,R=301]

This rule matches any URL pattern with a two-character language code followed by a slash and redirects it to the same path but prefixed with the dot notation.

  1. Clear Magento’s cache: After saving your changes, clear the cache from the admin panel (System > Cache Management).

Testing the Solution

Now, when you access site1.ca/fr, it will internally map to site1_fr while keeping the clean URL structure in the user’s browser.

The mod_rewrite rule ensures that:

  • The original URL with the store code prefix is recognized.
  • It redirects users to a cleaner URL without the store view code.

Conclusion

Managing multiple Magento websites with common language codes requires careful configuration and some creative use of mod_rewrite rules. By following this approach, you can maintain unique store view codes for each site while providing clean, user-friendly URLs that don’t compromise your website’s structure or performance.

Remember to backup your files before making changes and always test thoroughly in a development environment first. If you need further assistance with Magento configuration or URL rewriting, feel free to contact us for professional support.

Admin Configuration Errors

Our network