PHP Slim Framework Routing仅在本地工作

问题描述 投票:0回答:1

我使用Slim Framework进行路由构建了一些小东西。一切都在当地完美运作。我现在租了一个Droplet并在Ubuntu 18.04上使用LAMP堆栈。我的应用程序位于/var/www/src/public的位置。

我已将此添加到apache.conf中:

<Directory /var/www/src/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

我的000-default.conf已经设置了正确的路线。

我的.htaccess.txt位于/public,我的index.php包含:

RewriteEngine On

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

我已经为Apache启用了mod_rewrite

当我调用服务器IP地址时,主页面已成功加载到Slim,其中路由设置如下:

$app->get('/', function (Request $request, Response $response) {
    return $this->renderer->render($response, "/index.php");
});

所以Slim似乎正在渲染我的index.php,它正确地位于/var/www/views目录中。此路径在容器中定义如下:

$container['renderer'] = new PhpRenderer("../../views");

当我尝试访问网站ip_address/player时问题就开始了,即使它已正确路由并在本地运行。试图达到它在浏览器中给我这个:

Not Found
The requested URL /player was not found on this server.

我用谷歌搜索了几个小时尝试不同的解决方案,但我无法让它工作。任何帮助将不胜感激。

php apache ubuntu slim lamp
1个回答
0
投票

不应该是.htaccess而不是.htaccess.txt。你在用什么样的操作系统?

© www.soinside.com 2019 - 2024. All rights reserved.