【发布时间】:2016-11-16 07:18:21
【问题描述】:
在对 Slim 执行以下 Tutorial (9:48) 并测试 Slim 功能后,我仍然收到“找不到页面”。
程序应该在某个点之后回显在搜索栏中键入的任何单词,例如。如果搜索“http://localhost/authentication/public/test/Hello”,页面应该回显“Hello”,页面应该回显“Hello”。
这是通过使用 .htaccess 文件将任何链接重新路由到 index.php 来完成的。 index.php 文件然后运行名为 start.php 的 php 文件。
关于为什么这可能不起作用的任何建议?
Slim v3.x
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
index.php
<?php
require '../app/start.php';
$app->run();
?>
start.php
<?php
use Slim\App;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new App();
$app->get('/test/:name', function($name) {
echo "Hello! {$name}";
});
?>
【问题讨论】:
-
您使用 Apache Web 服务器吗? .htaccess 和 index.php 位于目录结构中的什么位置?您在哪个 URL 上直接访问您的 index.php,是 localhost/authentication/public/index.php?