我有一个Slim框架(版本2)的问题。如果我在默认页面上运行,它会显示没有问题的内容,但是当我请求类似$app->get('/test'...
的路由时,我总是会收到404错误。Slim Framework只返回404
这是我的index.php。
<?php
require 'vendor/autoload.php';
\Slim\Slim::registerAutoloader();
$app = new Slim\Slim();
// Welcome message.
$app->get("/", function() use($app) {
echo 'Appointment API<br />';
});
$app->get("/test", function() use($app) {
echo "This is a test";
});
$app->run();
我的.htaccess文件:
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
#RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [QSA,L]
而且我作曲文件:
{
"require": {
"slim/slim": "^2.6",
"slim/extras": "*",
"slim/middleware": "*"
}
}
为了这一点,我真的不知道该怎么办。
是由Apache或纤细提供404错误? – Federkun
该错误由Slim提供。我从slim得到默认错误页面 –
对我来说似乎很好。你可以尝试通过'/ index.php/test'访问吗? – Federkun