这是一个在dev env上完美运行的页面示例,并在prod env上返回404错误
未找到
在此服务器上找不到请求的网址 / app / reporter / 。 symfony.dev端口80上的Apache / 2.4.7(Ubuntu)服务器
不要让你自己被/ app / route混淆,这是一个真实的路线,与app.php无关
运行php app/console router:debug --env=prod
确实确认路由器没有问题:
[router] Current routes
Name Method Scheme Host Path
reporter ANY ANY ANY /app/reporter/
当然,在发布此消息之前,我:
无论如何,我的猜测是错误来自Apache,所以这里是我的conf:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName symfony.dev
SetEnv SYMFONY__TENANT__ID "123"
DocumentRoot /var/www/html/Symfony/web
# <Directory />
# Options FollowSymLinks
# AllowOverride None
# </Directory>
<Directory /var/www/html/Symfony/web >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-symfony.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access-symfony.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
在/var/www/html/
中,只有一个符号链接:
lrwxrwxrwx 1 root root 29 mai 13 2014 Symfony -> /home/me/path/to/symfony
并且我没有更改默认symfony /web/.htaccess
中的任何内容:
没有可读性评论
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
答案 0 :(得分:0)
Apache错误日志确认错误来自那里:
[negotiation:error] [pid 1583] [client 127.0.0.1:44590] AH00687: Negotiation: discovered file(s) matching request: /var/www/html/Symfony/web/app (None could be negotiated).
由于我对Apache的理解非常有限,我谷歌错误并找到了这个主题: http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm
所以我最终只是删除了我的vhost conf的MultiViews选项并解决了它。
如上所述,提及链接,
这将向您展示在您不确定他们做什么时简单地启用设置是多么糟糕。