1

I recently deployed a symfony project and noticed that the only way I can currently access the project is using the following URL:

http://domain.com/app.php/index

I was wondering if there is a way to automatically get the app.php to be served without actually including it in the URL.

Something like:

http://domain.com/index

Not sure if htaccess is required for this or if this is something that can be accomplished directly using Symfony.

This is what my htaccess currently looks like:

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

I appreciate any advice, thanks in advance!

3
  • The above .htaccess which you reference is very close to the one which I use in my own Symfony projects and I don't have issues with serving URL's omitting the app.php as part of the URL pattern. I do, however have the re-write base commented out. Commented Apr 21, 2014 at 21:06
  • Thank Sean. The above .htaccess isnt working for me. I tried removing the re-write base all together, still no success. I get an internal server error. Commented Apr 21, 2014 at 21:09
  • possible duplicate of RewriteRule in Apache with Symfony2 not removing app.php Commented Apr 21, 2014 at 21:20

1 Answer 1

0

This is (effectively) the .htaccess file which I use on several projects and sites using Symfony 2:

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

I also have the following vhost entry for one of my Symfony projects under the apache server:

<VirtualHost *> ServerAdmin admin@localhost DocumentRoot "<PATH_TO_PROJECT>/web" ServerName localhost ServerAlias localhost ErrorLog "<PATH_TO_PROJECT>/app/logs/apache_error.log" ErrorLogFormat "[%t] [%l] [pid %P] thread-%T %F: %E: [client %a] %M" <Directory "<PATH_TO_PROJECT>/web"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost>

The omission of the DirectoryIndex app.php index may be enough in the .htaccess file, so you could try that. Admittedly my knowledge of Apache configuration is weaker than I would like it to be, hopefully this helps, if not--hopefully some one out there can give you a better, stronger answer?

Best of luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.