简体   繁体   中英

Symfony2 vhost doesn't redirect to app.php

I've push my Symfony application on my server (Ubuntu 12.04, blog.dck.me) and when I go on, no problem but when you try to read an article, you've got a 404 error and then if you add app.php at first of the URL, it works !

It's not a rule problem, I fixed 777 for this folder. I cleared prod cache. I checked routing with php app/console router:debug --env=prod, it's ok i've got all route. I check many and many tim my vhost and when I change the DirectoryIndex to app_dev.php, the page print a javascript alert indicating "the toolbar can't be loaded" ..

My vhost :

<VirtualHost *:80>
ServerName blog.dck.me
DocumentRoot /var/www/blog/web
DirectoryIndex app.php
<Directory "/var/www/blog/web">
    DirectoryIndex app.php
    Options -Indexes FollowSymLinks SymLinksifOwnerMatch
    AllowOverride All
    Allow from All
    </Directory>
</VirtualHost>

I hope you'll get more idea.

Thank you.

If www.sitename.com/app.php works then it is not a problem of symfony and your vhost is okay. Also .htaccess is fine and you don't need to set DirectoryIndex app.php

have you checked that mod_rewrite is enabled? try this on your console:

    apachectl -t -D DUMP_MODULES | grep rewrite

if you don't have results then you need to enable it adding the line on httpd.conf

    LoadModule rewrite_module modules/mod_rewrite.so

Yes, there is :

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

after modifying your vhost file, have you been restarting your webserver?

eg, for apache,

sudo apachectl graceful

After many times, I founded the solution ! The problem was in my username.conf (/etc/apache2/users), in this file the keyword "FollowSymLinks" was missing.

<Directory "/Users/DCK/Sites/">
   Options FollowSymlinks Indexes Multiviews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM