I've the next .htaccess file during my web directory for my Symfony2 installation:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*) app.php [QSA,L]
</IfModule>

However, after i try something fundamental for example:

(whatever)/web/app.php/place

it does not getting rid of the application.php in the URL. I am a new comer to Apache and I am unsure what's happening here, can anybody shed some light? Thanks ahead of time!

EDIT: Because of the dwelling from the web application I'm dealing with I am unable to move application.php or application_dev.php outdoors from the web folder nor can one customize the server configuration of Apache in anyway, thus I'm searching for an alternate fix for your problem.

That rewrite rule isn't designed to remove app.php in the URL. It's purpose is by using app.php for each request, if a request URL does not match a genuine file. Since app.php is indeed a file, it will likely be accustomed to serve a request.

If you would like eliminate web/app.php part, first produce a virtual host pointing towards the web folder:

<VirtualHost *:80>
    ServerName whatever
    DocumentRoot /path/to/project/web
</VirtualHost>

This can take away the web part.

Then, to get rid of the app.php part, add this to the start of the web/.htaccess file:

RedirectMatch permanent ^/app\.php/(.*) /$1

Whenever you write RewriteCond %{REQUEST_FILENAME} !-f you say "Don't change real files... they ought to be obtainable." Should you remove that, it will work.

The main reason for this permitting that's some frameworks allow you to use http://site.tld/script.php/abc=123&def=456 type of links.

If you would like it to permit filenames except application.php, you could include that as the second RewriteCond.

I handled to get rid of web/application.php part on my small shared server.

  1. First I moved application.php from the web directory a measure above thus my application.php around the root directory. I Quickly placed b .htaccess around the root directory

RewriteEngine on

RewriteBase /

RewriteRule ^css/(.*) web/css/$1

RewriteRule ^images/(.*) web/images/$1

RewriteCond % !-f RewriteRule ^(.*)$ application.php [QSA,L]

I made use of RewriteCond on css and pictures because they still lie inside /web/ directory so that all request to css and pictures is going to be routed to web/css and web/images sites correspondingly.

It labored well for me personally.

We have been battling with that a lot. You will find two solutions:

  1. set document cause of your virtual host to suggest straight to the /web/ subfolder (according to Symfony2 guidance)
  2. move app.php and app_dev.php outdoors from the /web/ subfolder, then update .htaccess and can include pathways both in files accordingly (i.e. remove web/ to fix all pathways after you have by hand moved the files one folder above)

(Note: cannot provide good examples from vanilla installing of S2, since symfony.com appears to become lower right now.)