I recently deployed a symfony project and noticed that the dev environment is still accessible.
The following URL loads the prod version of the project:
http://domain.com/app.php/index
The following URL loads the dev version of the project:
http://domain.com/app_dev.php/index
I was wondering if it is possible to make the dev version of the project inaccessible in the prod environment?
I appreciate any advice, thanks in advance!
Add the following lines of code in your 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.');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.