如何使用slim框架从url中删除index.php?

时间:2021-08-06 11:18:50

I have this URL:

我有这个网址:

http://localhost:8082/sistemaTareas/api/index.php/hello/jean/bergeret

This prints:

HELLO JEAN BERGERET

I need to do the same, but with this:

我需要这样做,但有了这个:

http://localhost:8082/sistemaTareas/api/hello/jean/bergeret

I need config the .htaccess?

我需要配置.htaccess吗?

Edit: I saw the other answer, but did not solve my problem. Can anyone guide me?

编辑:我看到了另一个答案,但没有解决我的问题。谁能指导我?

1 个解决方案

#1


I think a AllowOverride All is missing in you website apache configuration, in order to activate your .htaccess.

我认为您的网站apache配置中缺少AllowOverride All,以激活您的.htaccess。

Your config file should look like this :

您的配置文件应如下所示:

<VirtualHost *:80>
        ServerName my.server.name
        DocumentRoot /path/to/your/website/root

        <Directory /path/to/your/website/root >
                DirectoryIndex index.php
                AllowOverride All  <!--Here-->
        </Directory>

</VirtualHost>

And your .htaccess like :

你的.htaccess就像:

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

#1


I think a AllowOverride All is missing in you website apache configuration, in order to activate your .htaccess.

我认为您的网站apache配置中缺少AllowOverride All,以激活您的.htaccess。

Your config file should look like this :

您的配置文件应如下所示:

<VirtualHost *:80>
        ServerName my.server.name
        DocumentRoot /path/to/your/website/root

        <Directory /path/to/your/website/root >
                DirectoryIndex index.php
                AllowOverride All  <!--Here-->
        </Directory>

</VirtualHost>

And your .htaccess like :

你的.htaccess就像:

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