diff --git a/web/src/app/app.php b/web/src/app/app.php index ce9bbb6..3f7ae5f 100644 --- a/web/src/app/app.php +++ b/web/src/app/app.php @@ -1,3 +1,5 @@ + + [ - '/' => 'public.home', + '/' => 'public.home', ], 'app' => [ - '/' => 'app.app', - '/login' => 'public.login', + '/login' => 'public.login', + '^\/.*$' => 'app.app', ], ]; diff --git a/web/src/index.php b/web/src/index.php index 24563f4..6053ec7 100644 --- a/web/src/index.php +++ b/web/src/index.php @@ -37,13 +37,19 @@ function module($ns, $die = false) { # module ROUTING module('config.routes'); -foreach ($routes['root'] as $path => $module) - if ($uri === $path) - module($module, true); - -foreach ($routes['app'] as $path => $module) - if ($app_uri === $path) - module($module, true); +$routes_config = [ + [ 'name' => 'root', 'base_uri' => $uri ], + [ 'name' => 'app', 'base_uri' => $app_uri ], +]; +foreach ($routes_config as $rcfg) { + foreach ($routes[$rcfg['name']] as $path => $module) { + if (substr($path, 0, 1) === '^' && + preg_match('/'.$path.'/', $rcfg['base_uri'])) + module($module, true); + if ($rcfg['base_uri'] === $path) + module($module, true); + } +} # /@username