奏鸣曲从网址中删除 /index.php

sonata remove /index.php from urls

我正在做一个 Symfony 2.8 / Sonata 项目,我发现所有 url 都是重复的,一个带有“/index.php”,另一个没有它。 所以这个 url :

http://mydomaine.com/index.php/test/test.html

将重定向到:

http://mydomaine.com/test/test.html

我尝试使用 .htaccess 删除它,但没有用:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/ [L]
    RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>

你有什么想法吗? 谢谢

将此规则放在 RewriteEngine On 下方,以从 URL 中删除 index.php

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php(/.+)$  [L,R=301,NE]