【发布时间】:2019-07-30 14:54:38
【问题描述】:
我使用 Slim 框架构建了一些小型路由。一切都在本地完美运行。我现在租了一个 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.
我已经用谷歌搜索了几个小时尝试不同的解决方案,但我就是无法让它发挥作用。任何帮助将不胜感激。
【问题讨论】:
-
我解决了这个问题,因为我有一个简单的问题...... .htaccess 是一个 .htaccess.txt。这真的很尴尬lol
标签: php apache ubuntu slim lamp