Symfony-使开发环境在产品中不可访问


Symfony - Making dev environment inaccessible in prod

我最近部署了一个symfony项目,并注意到开发环境仍然可以访问。

以下URL加载项目的产品版本:

http://domain.com/app.php/index

以下URL加载项目的开发版本:

http://domain.com/app_dev.php/index

我想知道是否有可能使项目的开发版本在prod环境中无法访问?

我很感激任何建议,提前谢谢!

在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 (!in_array(@$_SERVER['REMOTE_ADDR'], array(
                                          '127.0.0.1',
                                           '::1',)))
 {
  header('HTTP/1.0 403 Forbidden');
  exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more    information.');
 }