symfony2 rewrite rules .htaccess app.php
Try this in your .htaccess file (inside the web directory):
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On # Explicitly disable rewriting for front controllers RewriteRule ^app_dev.php - [L] RewriteRule ^app.php - [L] RewriteCond %{REQUEST_FILENAME} !-f # Change below before deploying to production #RewriteRule ^(.*)$ /app.php [QSA,L] RewriteRule ^(.*)$ /app_dev.php [QSA,L]</IfModule>
To improve upon whistlergreg's answer, I added a line so that the bundles folder is not broken. This will make sure external resources such as images are not broken.
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On # Explicitly disable rewriting for front controllers RewriteRule ^/web/app_dev.php - [L] RewriteRule ^/web/app.php - [L] # Fix the bundles folder RewriteRule ^bundles/(.*)$ /web/bundles/$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f # Change below before deploying to production #RewriteRule ^(.*)$ /web/app.php [QSA,L] RewriteRule ^(.*)$ /web/app_dev.php [QSA,L]</IfModule>
You don't have enabled rewrite module. This code is executed if mod_rewrite.c is enabled. You must only enable mod_rewrite in apache2.http://www.unixmen.com/how-to-enable-and-disable-apache-modules/
For example in Ubuntu:
sudo a2enmod rewritesudo service apache2 restart