PHP AltoRouter仅提供基本URL

我是PHP的noobie,我正在使用AltoRouter设置一个简单的路由.下面是我的index.PHP和.htaccess文件,它们位于路径文件夹中,即/ var / www / html /
我正在使用Apache2来提供网页.

的index.PHP

<?PHP
require 'vendor/AltoRouter.PHP';

$router = new AltoRouter();
// map homepage
$router->map('GET', '/', function () {
    require __DIR__ . '/views/home.PHP';
});

$router->map('GET|POST', '/login', function () {
    require __DIR__ . '/views/login.PHP';
});

$router->map('GET', '/signup', function () {
    require __DIR__ . '/views/signup.PHP';
});

$match = $router->match();

// 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');
}
?>

的.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.PHP [L]

问题:
当我访问localhost时,’home.PHP’被送达,但当我访问’localhost / login’或’localhost / signup’时,我收到404错误.

解决方法:

我希望你能访问localhost / login.PHP.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...