php/symfony2 hiding app.php from the URL
apache, php, symfony, url-rewriting
Solution
Compared your rules with symfony-standard .htaccess, I saw that you missed file checking before 'pass everything rule'. Try to
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
Problem
Consider the following URL : http://www.myurl.fr/accueil. It won't work. However http://www.myrurl.fr/app.php/accueil does work. I got rid of the .htaccess file because I want to use the vhost file and rely on Apache routing. My vhost file is as follow: ``` <VirtualHost my.ip.address> ServerName myurl.fr ServerAlias www.myurl.fr DocumentRoot /var/www/mysite/web DirectoryIndex app.php <Directory "/var/www/mysite/web"> AllowOverride All Allow from All </Directory> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L] RewriteRule .? - [L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ app.php [QSA,L] RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteRule .? %{ENV:BASE}app.php [L] </IfModule> </VirtualHost> ``` I've cleared Apache cache and restarted it many times. The urlrewrite mod is enabled. I just don't know what else to check. Any idea what I'm missing ? EDIT It could be that both URL won't work at a given time since I'm working on it. My issue is still valid.