php - Config Symfony3 URL

334

I use a debian server and I want change my URLipAdresse:9999/app.php/register withisAdress/register.

I have succeed to remove the.../web/.... But not the.../app.php/...

I have a virtual host :

Listen ipAdress:9999

<VirtualHost ipAdress:9999>
        DocumentRoot "/var/www/SuperSwungBall/web"
        DirectoryIndex app.php


        <Directory "/var/www/SuperSwungBall/web">
                AllowOverride All
                Allow from All
        </Directory>
</VirtualHost>

And a .htaccess in ~/web :

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

I have also tried with the default symfony ~/web/.htaccess . But, it doesn't work.

Thanks !

563

Answer

Solution:

This article describes a couple of examples on how to configure your webserver to route all requests through app.php with clean URL's: http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html

In your case your virtual host should look something like:

<VirtualHost *:9999>    
    DocumentRoot /var/www/SuperSwungBall/web
    <Directory /var/www/SuperSwungBall/web>
        AllowOverride None
        Order Allow,Deny
        Allow from All

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

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    <Directory /var/www/SuperSwungBall/web/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

People are also looking for solutions to the problem: php - How to select username in a given query in Joomla?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.