I can't access to My web site Symfony [ You are not allowed to access this file ]

M-BNCH picture M-BNCH · May 19, 2015 · Viewed 22.7k times · Source

I hosted my website; a Symfony2 application, whene I try to Access to my website this message is show.

You are not allowed to access this file. Check app_dev.php for more information

The link is :

http://something.com/web/app_dev.php/

When I try to access in production mode, this is the message :

Fatal error: Class 'AppBundle\AppBundle' not found in /htdocs/app/AppKernel.php on line 19

I don't have this folder htdocs in / of my hosting

Answer

Michael Sivolobov picture Michael Sivolobov · May 20, 2015

You faced the problem of authorization to dev-environment.

If you open app_dev.php you will see next code:

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

It acts as defender from other man to get access to your dev-env.

You can add your IP to the trusted IPs list and all will work fine. Trusted IPs defined in array in the code:

array('127.0.0.1', 'fe80::1', '::1')