I've deployed my Symfony2 project to my development server and want to run the dev environment.
Everything is running fine if I use /app.php but if I try app_dev.php I get a 404 error:
The requested URL /app_dev.php was not found on this server.
Below 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, just not on my development server, any ideas why?
My /cache and /logs directories are both have 777 permissions and are owned by 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 within these directories are exactly the same.
Check your app_dev.php it has a restriction to deny access to the dev environment from other computers than the server itself.
This is for security reasons, if you deploy to a production server and a user would have access to dev env, then he/she could know 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 to that array, or remove the whole thing (I wouln't recommend that).
Always remember passing the dev variable to AppKernel. $kernel = new AppKernel('dev', true);