Redirects don't seem to work with umlauts in the old urls

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:

/wir-über-uns/ >> /wir-ueber-uns
/wir-%C3%BCber-uns/ >> /wir-ueber-uns

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…

Aaaaaand i managed to fix it. :smiley: Although I don’t really understand how or why this works, here you go:


Still enough of a match, and redirects perfectly.


Try the following without the trailing /:

  '/wir-%C3%BCber-uns': '/wir-ueber-uns'
  '/wir-.*ber-uns': '/wir-ueber-uns'
  '/wir-.{6}ber-uns': '/wir-ueber-uns'

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:

$pattern = #^\/wir-(.*)\/#         <--- with trailing slash (=your pattern transformed into PHP pattern)
$replace = '/wir-ueber-uns' 
$source_url = /wir-%C3%BCber-uns   <--- without trailing slash

The $pattern does not match $source_url.

See also code lines Pages.php:1069-1087