In Magento 1.7 and earlier versions, when you enable the “Add Store Code to Urls” feature in Configuration->Web panel there are two minor bugs that affect your web store.

  1. Changing language (store view) in frontend produce a 404 error
  2. Download links of product options file in backend does not work: redirect you to dashboard page


  1. Modify this file: /app/code/core/Mage/Core/Model/Url/Rewrite.php around line 252comment line:
    // $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();

    and substitute with this code:

                if (Mage::getStoreConfig('web/url/use_store') && $storeCode = Mage::app()->getStore()->getCode()) {
                  $targetUrl = $request->getBaseUrl(). '/' . Mage::app()->getStore()->getCode() . '/' . $this->getRequestPath(); } 
                  $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();
  2. Modify this file: /app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php around line 526comment line:
    //$this->_getOptionDownloadUrl($urlRoute, $urlParams),

    and subsitute with this code:

                  str_replace("index.php/admin", ONE_OF_YOUR_STORE_CODE,
                              $this->_getOptionDownloadUrl($urlRoute, $urlParams)),

10 Responses to “Magento 1.7 enabling store code URL rewrite bug in frontend and backend”

  1. carlos

    I’m using Magento and in my rewrite.php and file.php files I can’t find the code that we have to modify…
    What can I do?

    • admin

      Hi Carlos, you have to search the lines of code we posted without the two initial comment slashes

  2. Anish

    Hello folks this is not working in Magento

    Can someone please help???

    Would I be able to downgrade to Magento while my database is already live in I have used another hack in languages.phtml to redirect to home page when language is changed instead of 404

    This is a serious bug.

    Although, it works if category/product name are same in both languages.

    Thanks in Advance

  3. Yogesh

    HI ,

    I am not getting any chages with this code but i try to change index.php/admin with uk and i can’t get fault of my can you help me …!


Leave a Reply

  • (will not be published)