Remove index.php from URL after query params without using .htaccess Remove index.php from URL after query params without using .htaccess php php

Remove index.php from URL after query params without using .htaccess


If you are using Apache 2.4, and do not want to to use .htaccess files (e.g. for performance reasons), the solution is simply to use a oneliner: FallBackResource.

You would only need this:

<VirtualHost *:80>    ServerName domain.tld    ServerAlias www.domain.tld    DocumentRoot /var/www/project/public    DirectoryIndex /index.php    <Directory /var/www/project/public>        AllowOverride None        Order Allow,Deny        Allow from All        FallbackResource /index.php    </Directory>    # optionally disable the fallback resource for the asset directories    # which will allow Apache to return a 404 error when files are    # not found instead of passing the request to Symfony    <Directory /var/www/project/public/bundles>        FallbackResource disabled    </Directory></VirtualHost>

This is even shown in Symfony's documentation.