symfony 2.8 no funciona el routing en prod

Hola, saludos a todo el foro. Necesito ayuda con esto: He puesto mi primera práctica en producción a ver qué tal se me daba y me he encontrado con que sólo puedo acceder a la página principal con ruta /. A las demás, por ejemplo www.puchi.com/login me da un error 404. ¿Qué se me ha pasado? Gracias por adelantado

He testeado:

php bin/console debug:router

... login ANY ANY ANY /login ...

php bin/console debug:router login

+--------------+---------------------------------------------------------+ | Property | Value | +--------------+---------------------------------------------------------+ | Route Name | login | | Path | /login | | Path Regex | #^/login$#s | | Host | ANY | | Host Regex | | | Scheme | ANY | | Method | ANY | | Requirements | NO CUSTOM | | Class | Symfony\Component\Routing\Route | | Defaults | _controller: AppBundle:Security:login | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | expose: true | +--------------+---------------------------------------------------------+

php bin/console router:match /login

[OK] Route "login" matches

+--------------+---------------------------------------------------------+ | Property | Value | +--------------+---------------------------------------------------------+ | Route Name | login | | Path | /login | | Path Regex | #^/login$#s | | Host | ANY | | Host Regex | | | Scheme | ANY | | Method | ANY | | Requirements | NO CUSTOM | | Class | Symfony\Component\Routing\Route | | Defaults | _controller: AppBundle:Security:login | | Options | compiler_class: Symfony\Component\Routing\RouteCompiler | | | expose: true | +--------------+---------------------------------------------------------+

En web/app.php:

cat web/app.php

<?php

use Symfony\Component\HttpFoundation\Request;

/* @var \Composer\Autoload\ClassLoader $loader / $loader = require DIR.'/../app/autoload.php'; //include_once DIR.'/../var/bootstrap.php.cache';

$kernel = new AppKernel('prod', true); $kernel->loadClassCache(); //$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter Request::enableHttpMethodParameterOverride(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);

php bin/console cache:clear --no-warmup -e prod --no-debug

// Clearing the cache for the prod environment with debug false

[OK] Cache for the "prod" environment (debug=false) was successfully cleared.

Respuestas

#1

Hola, he dado con una solución redefiniendo los rewrite en la configuración del sitio en apache2.

Aqui parte del archivo de configuración /etc/apache2/sites-available/000-default.conf: ...

Options Multiviews Options FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^app.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule .? - [L] RewriteRule .? %{ENV:BASE}/app.php [L] # RewriteRule ^app.php - [L] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule ^{.*}$ /app.php [QSA,L]

...