Magento site with multiple store setup, different root category for each store, yet all products are visible from anywhere within the same website. Product url rewrites are enabled.

Say I'm browing a store in my Magento site, and I navigate to a category page:


Say I bookmark this link for later, or to share on social networks. Then I switch stores and go to Electronics. I look at some items and then go away. My session saves the last store I visited. I then come back by click the url on Facebook, or by going to the bookmark. I get a 404 Error because the category page for Furniture / Living-room doesn't exist in Electronics. The router doesn't find any categories of that name in that store so it redirects to noroute. If I switch back to the first store manually (through the store switcher) and try the link again it works just fine.

How can I switch to the appropiate store so that the category page will display correctly? My guess is it would have to be before the url is passed to the routers but I don't know whether that's possible.

With products it is not the case; I can still view the product but I stay in the different store (electronics) so I would also like to be able to switch the store automatically.

Just by looking at the url http://example.com/furniture/living-room.html I cannot tell if it's a product url or a category url from the code. If I knew what I was trying to look at, I could find the appropiate store from the root category and switch to it programmatically.

Note: I do know how to switch stores programmatically. I just need to figure out how to do it from a rewriten url.

1 Answer 1


Sounds like you want System > Config > Web > Add Store Code to URLs. This should track the site you are on in the URL query string.

  • Sounds good but the project manager doesn't want the store code in the urls for SEO reasons. We want to make it look like it's one single store and website. I was wondering if I could do something like: $request->getPathInfo() == $product->getProductUrl() || $request->getPathInfo() == $category->getCategoryUrl()
    – Vic
    Mar 30, 2015 at 17:57
  • 1
    We ended up with a completely different setup, but this would be the answer to my original query.
    – Vic
    Apr 19, 2015 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.