Magento – Multi store view confusion, page 404’s redirects and Magento store codes

404categoryoverridesurl

I have set up several store views(for different languages), all under the same website and store.

The languages appear nicely, and I can switch between them. I have created several categories and started to localize them. All was going nicely.

The way I have set up the categories was like this(example):
/women (name:"Women", slug:"women")
–>shoes (name "Shoes", slug: "shoes")

And one of it's translations:

/zhen (name:"Zhen", slug:"zhen")
–>obuv (name:"Obuv", slug:"obuv")

I could see my products, categories appear on the website and I could switch between languages using the language switcher.

Now, the problems arose when I noticed that I could only get to see the pages in other languages if I used the language switcher. If I copy pasted a mysite.com/zhen/obuv into an incognito window, it would show me a 404. So in other words, If I sent the link to a person, he would also get the 404. So the only way to see the page in other languages was to use the language switcher(which presumably wrote a cookie to the browser), which would allow to see the localized category/page of the website.

I have checked URL rewrites in the Magento settings, they do look correct, i.e. both of those slugs/url are pointing to the same category(target path).

I have tried everything, emptying the URL rewrite table. Re-indexing, clearing cache, checking and re-checking all setting for store views/categories etc.

Then I've tried to set the "Add Store Code to Urls" to Yes. Which resolved all the problems, but also added a mysite.com**/en/** store codes to every page/store. Now it works more or less ok.

My questions are:
1. Where the URLs not resolving because it is not intended to be used that way(in the case of multi store)? (All things should have the same slug in case that I'm not suing store codes?)
2. Is it imperative to use store codes (like /en/) when trying to run a multi store view website?

Am I missing something here?

Best Answer

To get around this problem, you could consider using another URL for the second store view and then explicitly set that store ID -> then it would work.

Let's assume you have www.store.com

Then use for example www.store.com/de/ for the German store view (i.e. set this as the base URL for that store view in your backend).

In the index.php (or better using .htaccess logic) you should then detect that whenever there is /de/ in your URL, you set the store ID to your second store view.

That way, the URL of the translated store is uniquely detectable and everything will work out while you still keep the original URL for your main store.

Related Topic