I have a simple multi-language site with Chinese as one of the languages. I want to redirect all locales, e.g. /zh-cn
, /zh-tw
, /zh-hk
to /zh
. I’ve got a working route for that, but it “absorbs” all requests:
c::set('routes', array(
array(
'method' => 'GET',
'pattern' => '(:any)/(:all)',
'action' => function ($lang, $path) {
if (preg_match('/zh\-[a-z]{2}/', $lang)) {
go('zh' . DS . $path);
}
}
),
...
);
When I go to /zh-cn/foobar
, I correctly get redirected to /zh/home
. However, the new request matches the route too, but does not match the condition, and a blank page is returned. Also, all routes below this one are ignored. Is there a way to make Kirby behave a little bit like Apache or Nginx and process routes in a waterfall manner until it actually finds one that tells it what page to serve?
It would be ideal if, for example, I could return false
in the first route and make Kirby process all other routes until it finds one that doesn’t return false
.
Edit: I know I can switch the route to (zh\-[a-z]{2})/(:all)
and have it working. I am using this example only to simplify my question. In reality, I have more complex logic in the route that can’t be expressed through regex, so modifying the pattern is not an option for me.