我无法访问我的网站Symfony[您不允许访问此文件]


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

我托管了我的网站;Symfony2应用程序,当我试图访问我的网站

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

链接为:

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

当我尝试在生产模式下访问时,这是消息:

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

主机的/中没有htdocs文件夹

您遇到了dev-environment的授权问题。

如果你打开app_dev.php,你会看到下一个代码:

// 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.');
}

它作为其他人访问您的dev-env的防御者。

您可以将您的IP添加到可信IP列表中,一切都会正常工作。代码中数组中定义的可信ip:

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