Remove store code from URL in Magento

Remove store code from URL in Magento

August 11, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Remove store code from URL in Magento

Removing Store Code from URLs in Magento: A Comprehensive Guide

If you’re running multiple websites on a single Magento installation and want to remove the store code from your category, product, and CMS page URLs, you’ve come to the right place. This guide will walk you through the process step-by-step.

Understanding the Issue

When you have multiple websites configured in Magento, each site is associated with a specific store view and corresponding store code. By default, Magento includes this store code in the URL structure of your pages. For example:

While having the store code in the URL provides clarity for managing multiple sites within one installation, it’s often desirable to have clean URLs without these codes.

Step 1: Enable SEO-friendly URLs

Before we proceed with removing the store code, ensure that your Magento installation has SEO-friendly URLs enabled. Go to System > Configuration > General > Web.

Under the URL Options section, set the following:

  • URL Suffix (if you’ve configured any)
  • Base URL
  • Secure Base URL

Make sure the Use Web Server Rewrites option is set to “Yes”. This enables .htaccess rewriting, which Magento uses for SEO-friendly URLs.

Step 2: Modify Your .htaccess File

The core of removing the store code from URLs lies in modifying your .htaccess file. Here’s what you need to do:

  1. Open your Magento installation’s root directory.
  2. Locate and open the .htaccess file.
  3. Add the following lines at the end of the file, just before the closing </IfModule> tag:
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/$ $1 [L]
    RewriteRule ^([^/]+)/([^/]+)/?$ $2/$1 [L]
</IfModule>
  1. Save and close the file.

These rules use Apache’s mod_rewrite module to rewrite URLs without the store code. The first rule handles requests for single-level directories, and the second rule handles requests for multi-level directories.

Step 3: Configure Your Base URLs

Next, you need to ensure your base URLs are correctly configured in Magento:

  1. Go to System > Configuration > General > Web.
  2. Click on the Default Config or “Current Configuration Scope” button to access the global configuration.
  3. Under Base URL, set both the Base URL and Secure Base URL fields without including any store code (e.g., www.site1.com for Site 1).

Step 4: Flush Magento Cache

After making these changes, flush your Magento cache to ensure the new settings take effect:

  1. Go to System > Cache Management.
  2. Click “Flush Magento Cache”.

Conclusion

Removing store codes from URLs in a multi-store Magento installation requires understanding Apache’s mod_rewrite capabilities and properly configuring your base URL settings. By following this comprehensive guide, you should now have clean URLs without the store code for both Site 1 and Site 2.

Remember to test these changes thoroughly before deploying them to a live environment. Always back up your .htaccess file before making any modifications to ensure you can easily revert if needed.

If you’re looking for more advanced Magento customizations, consider reaching out to our expert development team at Laravel Company. We specialize in delivering high-quality e-commerce solutions tailored to your business needs.

Catalog Configuration SEO Errors

Our network