Multilanguage store as symlinked subdirectory on nginx returning 'no route to page'
-
12-12-2019 - |
Question
we needed to set-up our multi language store using the subdirectory/symlink
method described here. (read why @ bottom)
How we did it.
We copied index.php to a subdirectory and symlinked all folders. The base url
was set to domain.com/en
Problem/Question Now when I open domain.com/en I can see the website and it shows the English version. Only thing is that all category and product links produce a 'no route to page' error. Instead of showing the category or product. Now how can this be?
Example
So https://domain.com/en/funkyshoes
does not open the category funkyshoes, and neither does funkyshoes https://domain.com/funkyshoes
for that matter.
https://domain.com/en/funkyshoes
returns => no route to page
https://domain.com/funkyshoes
returns => https://domain.com/en
why not? because we have more than 1 multistore and cannot give every store a lang store_code like en/de/fr & also we have one multistore with different domains per store and the other using the /en, /de, /fr method from the main domain.
Solution 2
An even better solution is:
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite /(../)? /$1index.php?$args;
}
because we had some special location rules for catalog|checkout|customer. The problem being that thay all referenced @rewrite - this way we had to rewrite ALL the location commands that were set-up to also have a separate match for /en and later /fr and /de .....
So we came up with the simplest fallback rewrite that test first for / and then for /(two-letter code) .... and rewrites based on that
seems to work fine
In addition the store_code lookup needs to be altered. Because of the /en the http_host variable or server variable do no longer work.
A possible solution can be found here: https://stackoverflow.com/questions/30078679/nginx-conf-w-multiple-maps-to-same-variable
OTHER TIPS
This is an NGINX problem.
Adding this to a conf file solved our problem
location /en {
rewrite ^/en(.*)$ /en/index.php last;
}