How do I get rid of the need for "/app.php/" in the new URL to create Symfony2 applications?

I did the first install of Symfony2,

    php app/console --version
        Symfony version 2.0.11 - app/dev/debug

I installed it in an existing DocumentRoot by setting up apache2 vhost server

    <VirtualHost 127.0.0.1:80>
        ...
        DocumentRoot /srv/www/localhost_www
        ...
        <Directory "/srv/www/localhost_www" >
            AllowOverride none
            Options -ExecCGI +FollowSymLinks +Includes +Indexes +MultiViews
            Order Allow,Deny
            Allow from All
        </Directory>
        ...
        Alias /TESTAPP  "/srv/www/TESTAPP/web/"
        <Directory "/srv/www/TESTAPP/web/">
            Options All
            AllowOverride All
            Allow from All
        </Directory>

        Alias /TESTAPP.symfony  "/srv/www/TESTAPP/"
        <Directory "/srv/www/TESTAPP/">
            Options All
            AllowOverride All
            Allow from All
        </Directory>
        ...

After installing OK and successfully following the "Book" to create a demo application "Hello" if I find the browser in any / all,

  dev:
        http://localhost/TESTAPP.symfony/web/app_dev.php/hello/ME
        http://localhost/TESTAPP/app_dev.php/hello/ME
  prod:
        http://localhost/TESTAPP.symfony/web/app.php/hello/ME
        http://localhost/TESTAPP/app.php/hello/ME

I see the expected

"Hello ME!"

I want to rewrite only production URLs, hiding "app.php" so that the following set of URLs works in the browser navigation bar for my Symfony2 application:

  dev:
        http://localhost/TESTAPP.symfony/web/app_dev.php/hello/ME
        http://localhost/TESTAPP/app_dev.php/hello/ME
  prod:
     !! http://localhost/TESTAPP.symfony/web/hello/ME
     !! http://localhost/TESTAPP/hello/ME

Iiuc, default website /.htaccess

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

need to change.

​​ , vdiffferent RewriteRule, "RedirectMatch Permanent" ..,

http://localhost/TESTAPP/hello/ME

. , "/app.php/".

, , ?

.


@chasen

mod_rewrite apache?

.htaccess -

i do

, -,

, ,

    Alias /TESTAPP  "/srv/www/TESTAPP/web/"  
        <Directory "/srv/www/TESTAPP/web/">  

app.php .

. .

,

    https://localhost/TESTAPP/app.php/hello/ME

:

", !"

    https://localhost/TESTAPP/hello/ME

Object not found!

The requested URL was not found on this server.
If you entered the URL manually please check your
spelling and try again.

If you think this is a server error, please contact
the webmaster.
Error 404
+5
3

, , mod_rewrite apache?

.htaccess - , -, app.php .

ubuntu , :

sudo a2enmod rewrite
sudo service apache2 reload
sudo service apache2 restart

mod apache.

EDIT:

, , symfony? , prod , symfony :

php app/console cache:clear --env="prod"

EDIT:

, RewriteBase htaccess:

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

, AllowOverride None, AllowOverride All. Apache, , .htaccess . Apache , (https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles):

: - "/etc/apache2", "apache2.conf":

<Directory /var/www/>
    Options FollowSymLinks
    AllowOverride All
    Require all granted

  • :/etc/apache2 # service apache2 restart

. , 1 , .htaccess . , .

+3

RewriteBase , .htaccess, ! !

RewriteBase /project_name
0

All Articles