Symfony docs offer this direct solution to this problem.
'<VirtualHost *:80> ServerName domain.tld ServerAlias www.domain.tld DocumentRoot /var/www/project/web <Directory /var/www/project/web> AllowOverride None Order Allow,Deny Allow from All <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] </IfModule> </Directory> # uncomment the following lines if you install assets as symlinks # or run into problems when compiling LESS/Sass/CoffeScript assets # <Directory /var/www/project> # Options FollowSymlinks # </Directory> # optionally disable the RewriteEngine for the asset directories # which will allow apache to simply reply with a 404 when files are # not found instead of passing the request into the full symfony stack <Directory /var/www/project/web/bundles> <IfModule mod_rewrite.c> RewriteEngine Off </IfModule> </Directory> ErrorLog /var/log/apache2/project_error.log CustomLog /var/log/apache2/project_access.log combined </VirtualHost>'
One thing I would like to add to this discussion is that none of these excellent suggestions will bear fruit without further consideration.
If you are working with Apache, you should definitely enable mod_rewrite!
`sudo a2enmod rewrite`
So, if you bang your head against a wall, wonder why nothing works, try this. It can save your sanity and your project! Happy coding!
source share