[英]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 ! 我已将我的Symfony应用程序推送到服务器(Ubuntu 12.04,blog.dck.me)上,继续进行时没问题,但是当您尝试阅读文章时,出现404错误,然后添加了应用程序URL开头的.php可以正常工作!
It's not a rule problem, I fixed 777 for this folder. 这不是规则问题,我为此文件夹修复了777。 I cleared prod cache.
我清除了产品缓存。 I checked routing with php app/console router:debug --env=prod, it's ok i've got all route.
我用php app /控制台路由器检查了路由:debug --env = prod,没关系,我有所有路由。 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" ..
我检查了许多虚拟主机,当我将DirectoryIndex更改为app_dev.php时,页面上打印了一个JavaScript警报,指示“无法加载工具栏”。
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. 如果www.sitename.com/app.php可以工作,那么这不是symfony的问题,您的虚拟主机也可以。 Also .htaccess is fine and you don't need to set
DirectoryIndex app.php
.htaccess也很好,您不需要设置
DirectoryIndex app.php
have you checked that mod_rewrite is enabled? 您是否检查过启用了mod_rewrite? 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 如果没有结果,则需要启用它,并在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? 修改vhost文件后,您是否正在重新启动Web服务器?
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.
问题出在我的username.conf(/ etc / apache2 / users)中,此文件中缺少关键字“ FollowSymLinks”。
<Directory "/Users/DCK/Sites/">
Options FollowSymlinks Indexes Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.