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.

douju7503
douju7503 我修复了这个因为我有一个简单的问题....htaccess是一个.htaccess.txt。这真是令人尴尬的哈哈
一年多之前 回复

1个回答



不应该是.htaccess而不是.htaccess.txt。 你在哪种操作系统?</ p>
</ div>

展开原文

原文

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

duannian3494
duannian3494 那是我的问题。 它是在Ubuntu 18.04上
一年多之前 回复
dpvhv66448
dpvhv66448 你能帮助你,接受我的回答吗?
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问