Magento – Multi-Store Rewrites and htaccess (index.php)

.htaccessmagento-1.9multistoreurl-rewrite

Outline

I am running internationalized magento stores under sub-directories with sys-links created for every sub-directory and own index.php and .htaccess

  • fashion.co.uk – default store
  • fashion.com – enter page
  • fashion.com/us/ – American store view
  • fashion.com/eu/ – European store view
  • fashion.com/au/ – Australian store view

Problem

When accessing any of the internationalized stores, the URLs can not be accessed as of 404 error. When I disable Use Web Server Rewrites for these stores the URLs are accessible as:

  • www.fashion.com/us/index.php/new/bras

When above is enabled the accessed link looks like below but 404 error appears.

  • www.fashion.com/us/new/bras – 404

How do I remove/rewrite the index.php from all the urls making all the links work?


Structure

The 'default store' is simply under 'public_html' directory and within root I have internationalized sub-directories.

The 'default store' has:

  • Add Store Code to URLs: No
  • Auto-redirect to Base URL: No
  • Use Web Server Rewrites: Yes

The 'American, European & Australian store view' has:

  • Use Web Server Rewrites: Yes
  • Base & Secure URL: http:// www.fashion.com/us/
  • Base & Secure URL: http:// www.fashion.com/eu/
  • Base & Secure URL: http:// www.fashion.com/au/
  • Base URLs: Use Website

.htaccess (Addon)

SetEnvIf Host www\.fashion\.com/us/ MAGE_RUN_CODE=us_en
SetEnvIf Host www\.fashion\.com/us/ MAGE_RUN_TYPE=store
SetEnvIf Host ^fashion\.com/us/ MAGE_RUN_CODE=us_en
SetEnvIf Host ^fashion\.com/us/ MAGE_RUN_TYPE=store

SetEnvIf Host www\.fashion\.com/eu/ MAGE_RUN_CODE=eu_en
SetEnvIf Host www\.fashion\.com/eu/ MAGE_RUN_TYPE=store
SetEnvIf Host ^fashion\.com/eu/ MAGE_RUN_CODE=eu_en
SetEnvIf Host ^fashion\.com/eu/ MAGE_RUN_TYPE=store

SetEnvIf Host www\.fashion\.com/au/ MAGE_RUN_CODE=au_en
SetEnvIf Host www\.fashion\.com/au/ MAGE_RUN_TYPE=store
SetEnvIf Host ^fashion\.com/au/ MAGE_RUN_CODE=au_en
SetEnvIf Host ^fashion\.com/au/ MAGE_RUN_TYPE=store

Best Answer

This .htaccess can't work. /us and so on are not part of the host name (I.e. the domain)

For your desired setup it's probably the best to set "add store code to URL" to "yes"

Related Topic