gebeer Posted December 2, 2021 Share Posted December 2, 2021 Hello all, didn't know how to better describe my problem in the thread title. So bare with me. Will try to explain my setup. - multilingual site with all necessary modules installed, including LanguageSupportPageNames - default lang is English. Default lang homepage URL performs a redirect to /en/. So default home URL is mysite.local/en/ - one of my languages is Chinese (name cn). Home URL for Chinese is mysite.local/cn/ Page tree with page names and URLs for chinese language: - home: mysite.local/cn/ -- cn: mysite.local/cn/cn/ << here is the problematic URL: page name = lang name --- page1 mysite.local/cn/cn/page1 (only active in en and cn) --- page2 mysite.local/cn/cn/page2 (only active in en and cn) Now if I visit mysite.local/cn/cn/ I get redirected to mysite.local/cn/ which results in homepage view. Visiting mysite.local/cn/cn/page1 redirects to mysite.local/cn/page1. Results in 404 Changing the page name 'cn' to something else like 'asia' would resolve the problem But it is not an option because the URL structure like /en/cn/ and /cn/cn/ is a requirement for the project. Tracing back the redirect with Debug::backtrace inside a before hook to Session::redirect reveals the following: In wire/core/PagesPathFinder.php l. 519 the array $parts, (in my case [0 => 'cn', 1 => 'cn']) is passed by reference to getPathPartsLanguage(array &$parts) In that method the language is determined from the first entry in the array $parts. In that process the first entry is removed by $segment = array_shift($parts) Since $parts is passed in by reference, the original array of 2 path elements is being reduced to 1. This results in a wrong path and redirection. When I change the code so that $parts is not being passed by reference, weird things start happening. Getting 404s for existing pages like mysite.local/cn/cn/page1 and even for default language mysite.local/en/cn/page1 ATM I'm lost and don't know how I can get the required URL structure to work as expected. So if any of you have an idea of what could be the culprit here, please let me know. Thank you for staying with me until here. Link to comment Share on other sites More sharing options...
horst Posted December 2, 2021 Share Posted December 2, 2021 Hi @gebeer, Not really knowing an answer, but first I would post this in github issues so that it gets ryans recognition. And one idea came to my mind as workaround until a solid solution is known, would it be possible to use in pw the /cn/asia/... structure and use apache mod_rewrite to make it read /cn/cn/... ? Have not tried, just an idea. Link to comment Share on other sites More sharing options...
gebeer Posted December 2, 2021 Author Share Posted December 2, 2021 3 minutes ago, horst said: Hi @gebeer, Not really knowing an answer, but first I would post this in github issues so that it gets ryans recognition. And one idea came to my mind as workaround until a solid solution is known, would it be possible to use in pw the /cn/asia/... structure and use apache mod_rewrite to make it read /cn/cn/... ? Have not tried, just an idea. Thank you for taking your time. The apache rewrite option will be the last resort if I cannot get PW to behave the way I would expect. Link to comment Share on other sites More sharing options...
gebeer Posted December 2, 2021 Author Share Posted December 2, 2021 UPDATE: I installed a multilang page from scratch and found that the behaviour is the same as with my other install which also is latest dev. On PW 3.0.189 dev mysite.local/cn/cn/ redirects to mysite.local/cn/ Whereas when I switch to 3.0.184 master, mysite.local/cn/cn/ throws a 404. Will go and file an issue. Meanwhile if any of you can enlighten me, that would be great. Filed an issue at GH https://github.com/processwire/processwire-issues/issues/1479 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now