Skip to content

Commit 8614419

Browse files
Avoid index.php duplication in security redirects
This change addresses environments where internal URL rewriting (e.g., via mod_rewrite) is unavailable, forcing the index.php entry point or script name to remain visible in the request path. When this 'dirty' absolute path is stored as a target for later redirection, Symfony's logic may prepend the script name again, resulting in duplication (e.g., /index.php/index.php/). Switching to an absolute URL (including scheme and host) prevents this re-processing. Fixes #1645
1 parent 781e485 commit 8614419

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Controller/SecurityController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\Routing\Attribute\Route;
19+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920
use Symfony\Component\Security\Http\Attribute\CurrentUser;
2021
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
2122
use Symfony\Component\Security\Http\Util\TargetPathTrait;
@@ -50,7 +51,7 @@ public function login(
5051
// page, after a successful login you are redirected to a page in the previous
5152
// locale. This code regenerates the referrer URL whenever the login page is
5253
// browsed, to ensure that its locale is always the current one.
53-
$this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index'));
54+
$this->saveTargetPath($request->getSession(), 'main', $this->generateUrl('admin_index', [], UrlGeneratorInterface::ABSOLUTE_URL));
5455

5556
return $this->render('security/login.html.twig', [
5657
// last username entered by the user (if any)

0 commit comments

Comments
 (0)