我正在尝试使用Slimframework并且遇到一些麻烦。我的目录结构如下
/var/www/html
rest
.htaccess
index.php
vendor
composer
slim
.htaccess包含以下内容
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
index.php如下
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {echo "Hello, $name";});
$app->run();
//echo 'xx';
?>
当我浏览example.com/rest/index.php
时我收到404错误。我确保我的Apache配置允许.htaccess,这不是问题。我认为我忽略了一些非常基本的东西,但我无法发现它。我非常感谢任何帮助。
答案 0 :(得分:1)
根据您尚未为/
定义路线的事实,对example.com/rest/index.php/hello/droid
和example.com/rest/hello/droid
的请求应按预期工作。