Then add RedirectAnonymousSubscriber.php for your custom event subscriber in use Symfony\Component\HttpFoundation\RedirectResponse; use . Use the following module to add a login redirect for anonymous users, .