Symfony Url Generator producing different URLs from the same Route before and after login Symfony Url Generator producing different URLs from the same Route before and after login php php

Symfony Url Generator producing different URLs from the same Route before and after login


I can see that "/articles/edit/test" and "http://localhost/testsite/articles/edit/test" are same url just with difference of site url in it.

if you use your "generateUrl" method as following it will generate always same url. It should generate "http://localhost/testsite/articles/edit/test" always

$url = $this->generateUrl('article_edit',array('alias' => 'test', UrlGeneratorInterface::ABSOLUTE_URL));

Also dont forget to use following class in namespace section

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;


Try setting your host inapp/config/services.yml

parameters:    router.request_context.host: www.yourdomain.com    router.request_context.scheme: http    router.request_context.base_url: /your/path

More Info:https://symfony.com/doc/3.3/console/request_context.html