Symfony2 app.php works, but not app_dev.php

I have deployed the Symfony2 project on my development server and want to run the dev environment.

Everything works fine if I use /app.php, but if I try app_dev.php, I get 404 error:

The requested URL / app_dev.php was not found on this server.

The following is a copy of my .htaccess file:

<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On # Explicitly disable rewriting for front controllers RewriteRule ^app_dev.php - [L] RewriteRule ^app.php - [L] RewriteCond %{REQUEST_FILENAME} !-f # Change below before deploying to production #RewriteRule ^(.*)$ app.php [QSA,L] RewriteRule ^(.*)$ app_dev.php [QSA,L] </IfModule> 

It works fine on my local machine, and not on my development server, any ideas why?

There are 777 permissions in the My / cache and / logs directories and belong to www-data:

 drwxrwxrwx+ 4 www-data www-data 4096 Mar 15 11:46 cache drwxrwxrwx+ 2 www-data www-data 4096 Mar 15 11:05 logs 

dev and prod in these directories are exactly the same.

+4
source share
1 answer

Check your app_dev.php, it has a restriction prohibiting access to the dev environment from other computers than the server itself.

This is for security reasons, if you are deploying to a production server and the user has access to dev env, then he / she can learn a lot about your application.

 // 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')) ) { header('HTTP/1.0 403 Forbidden'); exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } 

You must add your IP address to this array or remove all of this (I do not recommend doing this).

Always remember how to pass the dev variable to AppKernel. $kernel = new AppKernel('dev', true);

+7
source

Source: https://habr.com/ru/post/1469489/


All Articles