0
votes

Here's an example of a page that works perfectly fine on the dev env and returns a 404 error on the prod env

Not Found

The requested URL /app/reporter/ was not found on this server. Apache/2.4.7 (Ubuntu) Server at symfony.dev Port 80

don't let yourself confuse by the /app/ route, this in a real route and has nothing to do with app.php

running php app/console router:debug --env=prod does confirm there's no problem with router :

[router] Current routes
Name                                               Method Scheme Host   Path      
reporter                                           ANY    ANY    ANY  /app/reporter/      

Of course, before posting this message, I :

  • cleared the cache, with console cache:clear --env=prod, as well as directly deleting cache files but this didnt change anything.
  • double-checked mod_rewrite was on in phpinfo

Anyway, my guess is the error comes more from Apache so here's my 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>

in /var/www/html/, there's only a symlink:

lrwxrwxrwx 1 root root    29 mai   13  2014 Symfony -> /home/me/path/to/symfony

and i didnt change anything in the default symfony /web/.htaccess : without comments for readability's sake

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>
1

1 Answers

0
votes

Apache error log confirmed the error came from there :

[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).

As my understanding of Apache is seriously limited, i google the error and found this topic : http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm

So i ended up simply removing the MultiViews option of my vhost conf and it solved it.

As the above give link is mentionning,

This goes to show you how bad it is to simply enable settings when you are not sure what they do.