中音路由器无法正确路由

时间:2016-03-16 10:34:45

标签: php .htaccess altorouter

我已经创建了.htaccess文件,但是alto路由器的路由不是

<?php

require 'altorouter.php';

$router = new AltoRouter();
$router->setBasePath('/rimaxxApi/');
$router->map('GET', '/', function(){

  echo 'It is working';
});

$match = $router->match();

// Here comes the new part, taken straight from the docs:

// call closure or throw 404 status
if( $match && is_callable( $match['target'] ) ) {
    call_user_func_array( $match['target'], $match['params'] );
} else {
    // no route was matched
    header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}

?>

路径位于子文件夹中

使用此代码我不断收到“404”错误,但我已经定义了路由。

1 个答案:

答案 0 :(得分:1)

尝试$router->setBasePath('/rimaxxApi');