【问题标题】:Slim 3.8 framework failing to routeSlim 3.8 框架无法路由
【发布时间】:2018-03-08 18:56:17
【问题描述】:

我使用 slim 已经有一段时间了,今天我更新到 3.8,开箱即用我发现了一些东西

 $app->get('/', function ($request, $response) {
 return 'Slim working';
});



$app->get('/hello', function ($request, $response) {
return 'Slim hello also working';
});

第一个方法调用有效,第二个给我Object not found! 错误,我不明白出了什么问题,谁能帮我理解。

所以我的文件夹结构就像appname/public/index.php 我运行第一个方法只需调用appname/public/ 来运行第二个我像appname/public/hello 一样运行它

【问题讨论】:

  • 如果能附上错误sn-p就好了。
  • appname/public/index.php/hello 如果你没有重写 url

标签: php slim


【解决方案1】:

您需要使用以下规则在根目录(很可能是 appname/public)中添加 .htaccess 文件

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

希望它会起作用。

【讨论】:

  • 太棒了。谢谢!!
猜你喜欢
  • 2014-08-11
  • 2013-04-06
  • 2017-10-13
  • 1970-01-01
  • 1970-01-01
  • 2016-06-28
  • 2015-06-18
  • 2014-08-27
  • 2023-04-03
相关资源
最近更新 更多