我尝试在我的网站空间的子文件夹中使用 AltoRouter。但比赛总是假的!
我的网络空间上有这个结构
domain.com
--/2 --> subfolder
----index.php
----.htacces
我的 .htaccess 文件如下所示:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
所以我像这样设置路由器:
<?php
session_start();
require_once 'vendor/autoload.php';
use LemWebPortal\Config;
$latte = new Latte\Engine;
$router = new AltoRouter();
$router->setBasePath('/2/');
$router->map('GET', '/', function () {
require __DIR__ . '/src/Init/index.php';
});
$router->map('GET', '/schulungsbedarf', function () {
require __DIR__ . '/src/Init/courseRequest.php';
});
$match = $router->match();
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');
}
echo '<pre>';
var_dump($match);
现在,当我打电话domain.com/2/
或domain.com/2/schulungsbedarf
看到一个空白的白页时,会显示以下消息:
bool(false)
我在这里错过了什么?