Ask your Symfony questions! Pay money and get answers fast! (more info)

App not working unless showing controller in URL Symfony

I'm testing my Symfony 1.4 app in a development server using the following .htaccess file:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
RewriteEngine On

# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /

# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]

If I do it takes me to 404.

I have a route in routing.yml which is for the root address ( and that one works.

It only works if I add the controller file before, for example or frontend_dev.php as well

Do you know what could be causing this? it works fine in my local environment when I try it in production mode.

My settings.yml

error_reporting: <?php echo (E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR)."\n" ?>
no_script_name: true
logging_enabled: false

error_reporting: <?php echo (E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR)."\n" ?>
web_debug: true
cache: false
no_script_name: false
etag: false
logging_enabled: true

Answers (6)


Ben answers:

do you have apache mod_rewrite installed?
you can check this by making a phpinfo file.



fxsymfony comments:

mod_rewrite doesn't show there, but I read that it could still be installed, so I'm double checking with the server admin (it's a client's server so I don't have access to much)


José Nahuel Cuesta Luengo answers:

Have you tried going through Apache's logs to see what is going on under the hood?

That way you might see if there's a typo or configuration error.

Just a wild guess: is the URL a root one (like the you used)? or is it something like ? Try commenting out the
RewriteBase / directive.

fxsymfony comments:

yes it's a root one.


Martin Palacio answers:

if you deploy a symfony app under a subdirectory, ex. localhost/myapp, you must:

1) check if mod_rewrite is installed (as stated by Ben)
2) adjust the RewriteBase directive to match your subdirectory name, ex:

RewriteBase /myapp



Jakub Zalas answers:

Do you have mod_rewrite turned on? Could you paste your virtual host definition? Do you have "AllowOverride All" in there?

Use RewriteLog to debug your rewrite rules:

RewriteLog "/var/log/apache/rewrite.log"
RewriteLogLevel 3

Adapt path to log file and log level to your needs. "The default level 0 means no logging, while 9 or more means that practically all actions are logged." ([[LINK href=""]]see docs[[/LINK]]).

<strong>Note</strong>: Don't use this logger on production as it will significantly slow your website down.


Luis Cordova answers:

also paste your vhost.conf, are you on mediatemple?

you could rule out the stuff with a clean copy of a demo app 1.4, then if that does not fail

then check your project files for a setting that could be presenting the problem.


Milena Dimitrova answers:

Apart from mod_rewrite installed you need to have in your virtual host configuration:

AllowOverride All
Allow from All

(so that htaccess takes effect)

DirectoryIndex index.php index.html

(make sure index.php comes first)

See sample configuration for Jobeet:

You probably don't have access to the host configuration but the server admin can do it.