问题
I have provided a pre build project on symfony in which the logout session redirects to the login screen, but now i want that page to redirect on the home page instead. What i have found in the coding files is this:
in the base twig file:
<a href="{{path('log_out')}}"><i class="icon-key"></i> Log Out</a>
in routing.yml
#Route for logout page.
log_out:
pattern: /bid/logout
Do anyone know how to change this redirection please hep me out, i am a total newbie to symfony Thanks
回答1:
Normally it is redirect to home. Check your security.yml config file.
firewalls:
default:
logout:
path: /logout
target: / #This is home url
回答2:
On Symfony 4, by default, the logout action redirects to the / path. You can change the default behavior by setting the proper configuration parameter in the security.yml config file.
security:
...
firewalls:
...
main:
...
logout:
...
target: app_login # you can specify a hard coded URL path or a route name
回答3:
The easiest way, to my humble opinion, is to simply do a redirection in your logoutAction (so in your controller), like this :
public function myLogoutAction()
{
// Your logout logic
return $this->redirect($this->generateUrl('my_route'));
}
来源:https://stackoverflow.com/questions/30476384/symfony-how-to-redirect-to-home-page-after-logout