So I'm working on a relaunch, and the old site uses umlauts in some urls. This seems to break the redirects… Redirects without umlauts work fine. I tried them as-is and also encoded:
But both give me a Crikey error with "Call to a member function getRoute() on null". Not sure what the problem is. Possibly a bug? Any ideas are much appreciated!
I found some more forum posts and things on the internet, and this seems to be a general problem with the recognition, the parsing of umlauts in redirect urls. I found a nice idea for a solution: basically put some wildcards in place of the umlauts. However, I tried /wir-(.*)-uns/ which would be enough of a match, but that doesn't work either…
Note: Grav uses internally /wir-%C3%BCber-uns as current url. Note it has not trailing /.
Btw. I suspect the /wir-(.*)/, with the trailing /, doesn't work. Maybe a typo?
Why? Because the current Url retrieved by Grav (using $uri->uri(false)) does not contain a trailing slash. The current url returned is /wir-%C3%BCber-uns
That means the regex: preg_replace($pattern, $replace, $source_url) will fail with the following values:
PHP
$pattern=#^\/wir-(.*)\/# <--- with trailing slash (=your pattern transformed into PHP pattern)$replace='/wir-ueber-uns'$source_url=/wir-%C3%BCber-uns<---withouttrailingslash
I tried all your suggestions, and they work! They're neater, I like that. But apparently Grav's redirection mechanisms are a bit more complex than that. What I wrote was not a typo: /wir-(.*)/ with the trailing slash does redirect perfectly. However it seems that subdirectories cause some hiccoughs as well – I already found a solution though:
does NOT work: /news/gr.*nspecht-eg >> /blog/gruenspecht-eg