我正在尝试使用AltoRouter,但我正在尝试遵循它的文档,而我的问题是它$_GET
总是为空的。
我正在使用 Apache,我的 .htaccess 如下所示:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
现在这是我用来$_GET
制作路由器的文件:
$router->map('GET', '/', 'PageController@getShowHomePage', 'home');
$match = $router->match();
list($controller, $method) = explode("@", $match['target']);
if(is_callable(array($controller, $method))) {
$object = new $controller();
call_user_func_array(array($object, $method), array($match['params']));
} else {
echo "Cannot find $controller -> $method";
exit();
}
但我看到它不起作用,因为当我收到 $_GET 时,它总是空的,我用 aprint_r($_GET)
来查看 to $_GET
,但返回给我的是一个空数组。
我尝试使用以下 URL,但结果是相同的:
http://localhost/mvc/
http://localhost/mvc/page
http://localhost/mvc/controller
http://localhost/mvc/produto/cadastrar