我在一個基本的PHP應用(無框架)中使用Altorouter
,但不知何故它不起作用。以下是詳細信息:Altorouter不能執行路由
的index.php
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
require_once __DIR__ . '/vendor/autoload.php';
$router = new AltoRouter();
$router->map('GET', '/', function() {
include __DIR__ . 'home.php';
});
print "Done";
它打印完成和PHP的日誌中沒有錯誤。
htaccess的
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
我訪問它作爲'http://localhost/home/myapp/
也許應該是'包括__DIR__ 。 '/home.php';' – Phil
@菲爾仍然沒有工作。 – Volatil3
@Phil - 是的,我甚至會說使用'require'來代替。包含我發現的唯一真正的好處是,如果您返回像包含文件中的數組。否則,要求會失敗並告訴你缺少一個斜槓becase __DIR__不會將結尾斜槓添加到路徑。 – ArtisticPhoenix