0

I have a symfony2 project running with nginx and the problem is that when accessing the prod environment, all the links are still with app_dev.php there.

Here are my config files:

app.php

<?php

require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';

use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$kernel->handle(Request::createFromGlobals())->send(); 

The links in the twig file are called this way:

Route name: user_login, in twig: user_login_path()

Where could the problem come from? Nginx?

11
  • Do you mean /app.php redirects to /app_dev.php ? You may have some bad rewrite in a .htaccess or something ?
    – Brewal
    Jul 18, 2014 at 14:58
  • No, for example I open my page with app.php, everything is there except that all the href links on tha page are with app_dev.php on them. Jul 18, 2014 at 15:02
  • Ok... Do you use path('route_name') for the links href ?
    – Brewal
    Jul 18, 2014 at 15:04
  • No, I am using for example for the "user_login" route: user_login_path() Jul 18, 2014 at 15:07
  • You should edit your question with this but with more details.
    – Brewal
    Jul 18, 2014 at 15:08

1 Answer 1

1

You should always use path('route_name') in order to generate links or actions. It seems that the function(s) you are using (kind of twig extension) is bad coded and server dependent. But it does not comes with Symfony itself.

You have multiple options :

  • The cleanest : replace every href, action, ... with the path function
  • A (maybe) faster one : find the custom twig extension and make it work (more likely in src/Acme/MyBundle/Twig/MyExtension.php)
  • A quick and dirty one : rewrite every app_dev.php urls to app.dev with a .htaccess (not really recommended at all but... well...)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.