php 我无法访问我的网站 Symfony [您无权访问此文件]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30336232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I can't access to My web site Symfony [ You are not allowed to access this file ]
提问by M-BNCH
I hosted my website; a Symfony2 application, whene I try to Access to my website this message is show.
我托管了我的网站;Symfony2 应用程序,当我尝试访问我的网站时会显示此消息。
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
我没有这个文件夹htdocs
在/
我的主机的
回答by Michael Sivolobov
You faced the problem of authorization to dev-environment.
您遇到了对开发环境的授权问题。
If you open app_dev.php
you will see next code:
如果您打开,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.');
}
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:
您可以将您的 IP 添加到受信任的 IP 列表中,一切都会正常工作。代码中数组中定义的可信IP:
array('127.0.0.1', 'fe80::1', '::1')