Php slimframework404错误

Php slimframework404错误,php,routes,slim,Php,Routes,Slim,我尝试使用Slim框架,但我对路由系统有问题。我试图转到“/contact”,但我的web浏览器出现404错误。但是,当我尝试访问“/index.php/contact”时,服务器显示了良好的响应。以下是我的路线代码: $app->get('/', function (Request $request, Response $response, array $args) use ($app) { $response->getBody()->write("Hello me"

我尝试使用Slim框架,但我对路由系统有问题。我试图转到“/contact”,但我的web浏览器出现404错误。但是,当我尝试访问“/index.php/contact”时,服务器显示了良好的响应。以下是我的路线代码:

$app->get('/', function (Request $request, Response $response, array $args) use ($app) {
    $response->getBody()->write("Hello me");

    return $response; 
});

$app->get('/contact', function (Request $request, Response $response, array $args) {
    $response->getBody()->write("Contact page");

    return $response;
});
这是公共目录中的my.htaccess(与Slim framework官方网站的“第一个应用程序”教程中的相同):


提前感谢您的帮助

尝试使用此htaccess:
RewriteCond%{REQUEST\u FILENAME}上的RewriteEngine-f RewriteRule^index.php[QSA,L]
您的解决方案不起作用。Slim返回“不允许使用方法。必须是:GET:”之一(如果Slim返回“不允许使用方法…”,则路由工作正常。您需要使用GET方法,而不是POST。只需打开浏览器并使用URL
http://yourowndomain.com/contact
您没有修复我的问题,因为我想知道为什么在修复时会出现此错误消息“/contact”以及为什么我必须编写“/index.php/contact”才能在我只需要“/contact”的情况下工作。太粗鲁了!请发布你的.htaccess文件或虚拟主机配置设置。但在我看来,你在根路径上使用($app)似乎把事情搞砸了,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]