dsaff82024 2019-03-08 14:42
浏览 100
已采纳

PHP Slim Framework Routing仅在本地工作

I have built something small using the Slim Framework for routing. Everything worked perfectly locally. I have rented a Droplet now and use a LAMP stack on Ubuntu 18.04. My App is located in the location /var/www/src/public.

I have already added this into the apache.conf:

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

My 000-default.conf already has the correct route setted.

My .htaccess.txt is located in /public with my index.php which contains:

RewriteEngine On

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

I have already enabled mod_rewrite for Apache.

When I call the servers IP address the main page is loaded successfully with Slim where the routing is set like this:

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

So Slim seems to be rendering my index.php which is in the directory /var/www/views correctly. This path is defined in the container like this:

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

The problem starts when I try to reach for example the site ip_address/player even though it is correctly routed and was functioning locally. Trying to reach it gives me this in the browser:

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

I have googled for several hours trying different solutions but I just can't get it to work. Any help would be greatly appreciated.

  • 写回答

1条回答

  • doubi1624 2019-03-08 16:26
    关注

    Should not it be .htaccess instead of .htaccess.txt. What kind of OS you're at?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波