I'd like to add parameters on my routes that I use in yml, for example in security.yml
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: project_main_homepage
default_target_path: project_user_profile
failure_path: project_main_homepage
If I failed the login I will be redirect to project_main_homepage ( http://www.mywebsite.com ) but for example I'd like to be redirected to http://www.mywebsite.com?user=0 is there a solution to do that ?
Thanks
I don't think it is possible to add a URL get parameter directly in the security.yml file but this is totally possible by creating an authentication handler where you create your own RedirectResponse to a route (with parameters) of your choosing. Check this article on creating an authentication handler in symfony .
Another alternative is to create a second route that has a URL parameter to redirect to the same action, not sure if that would suit your needs since it would be a different URL.
Have you tried to add your parameters in /app/config/parameters.yml and to use them in routing.yml and in security.yml surrounded by %?
For example:
app/config/parameters.yml
your_param: xxx
app/config/routing.yml
your_route:
pattern: /%your_param%/{_locale}
defaults: { _controller: YourBundle:Main:index }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.