Symfony 2 - An error occurred while loading the web debug toolbar (404: Not Found)

允我心安 提交于 2019-11-29 13:13:54

I had this problem too, try to pay attention to your .htaccess and make it look like this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the startpage to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

In Symfony 4 + Flex i had to install symfony/apache-pack recipie

composer req apache-pack

I had this particular problem after installing my application on a fresh Linux box. I had just forgotten to activate mod_rewrite in Apache2

[sudo] a2enmod rewrite
[sudo] service apache2 restart

Hope it will help !

Another source of this error: update the Apache web server without uncommenting the rewrite module. Learn by doing!

I came across this error when I modify vendor code for debugging purposes. (I do know it is not the right way but anyway.. I did modifications, tested the web application and forgot to roll back vendor code).

If it is Your case and You do not remember where exactly You did "illegal" changes to vendor code, You can remove vendor directory or its components and run php composer.phar update command to pull the original versions.

your rewrite rules is probably causing it. Just few moments ago I was rewriting mine and I had the same issue with the profiler.

To me this happen when I changed .htaccess (from web dir) in order to call app_dev.php instead of app.php, but I didn't change it everywhere in .htaccess file. After changing it's all appearances to app_dev.php error disappeared.

just do a restart to your WAMP/LAMP, it's working for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!