php - AltoRouter 从不匹配子文件夹
问题描述
我尝试在我的网站空间的子文件夹中使用 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)
我在这里错过了什么?
解决方案
推荐阅读
- java - 无法将 Premium_Fragment 转换为 Activity
- wso2 - WSO2IS-5.3.0 的 OIDC SSO 中缺少声明
- javascript - 如果已经激活 JS,则停止切换
- css - 将除一类以外的所有字体设置为特定字体
- c# - 有没有更有效的方法来禁用多个脚本,同时在 Unity 中的单个游戏对象上保持一些活动?
- vb.net - vb.net - 发送邮件一段时间出错,或者建立
- kubernetes - 是否可以使用 python API 观看 Kubernetes 集群上的所有事件?
- jquery - 如何在按钮单击时更改 $.ajax url 源变量?
- arrays - 根据文件 1($1 和 $2)过滤文件 2
- javascript - 按动态键对嵌套对象数组进行排序