<IfModule mod_rewrite.c>
RewriteEngine On
### Call the correct front controller. This is dependent on an environment variable being set
### in the virtual host configuration. SetEnv seems not to work, so here's an example with SetEnvIfNoCase:
### <Directory /path/to/application/web>
### SetEnvIfNoCase REQUEST_URI .* SYMFONY_ENV=dev
### </Directory>
### This will force the following rules to call the dev front controller.
# Make sure the prod front controller is called without a suffix.
# (prod OR production) and file doesn't exist
RewriteCond %{ENV:SYMFONY_ENV} prod [OR]
RewriteCond %{ENV:SYMFONY_ENV} production
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
# dev
RewriteCond %{ENV:SYMFONY_ENV} dev [OR]
RewriteCond %{ENV:SYMFONY_ENV} development
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]
# any other front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{ENV:SYMFONY_ENV} ^(.+)$
RewriteRule ^(.*)$ app_%1.php [QSA,L]
# Default to prod if there is no variable set (most secure)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>