t.c
t.c

Reputation: 1257

sonata remove /index.php from urls

I am working on a Symfony 2.8 / Sonata project, and I found that all urls a duplicated, one with "/index.php" and the other witout it. So this url :

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

will be redirected to :

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

I tried to use .htaccess to remove it, but it didn't work :

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

Do you have any ideas ? Thanks

Upvotes: 1

Views: 80

Answers (1)

anubhava
anubhava

Reputation: 786319

Place this rule just below RewriteEngine On to remove index.php from URLs:

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

Upvotes: 1

Related Questions