Altorouter can't execute routes

自古美人都是妖i 提交于 2019-12-08 05:08:33

Ok I figured out the issue. The URL I want to access is:

http://localhost/home/myapp/

Altorouter does not know about root URL so basePath needs to be set. it is done as:

$router->setBasePath('/home/myapp');

Do note that there's no trailing / should be put in setBasePath because we will put that in our map function like that:

$router->map('GET', '/', 'home.php', 'home');
$match = $router->match();
if ($match) {
    require $match['target'];
} else {
    header("HTTP/1.0 404 Not Found");
    require '404.html';
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!