I have the following routes
hekdb_login_show:
path: /Login/showForm
defaults: { _controller: HEKdbBundle:Login:showForm }
hekdb:
path: /
defaults:
_controller: FrameworkBundle:Redirect:redirect
route: hekdb_login_show
permanent: true
(Actually there are more, but these two are sufficient.) The last route is supposed to redirect everyone that comes to the website with nothing more than "/" after the hostname is redirected to the login form.
The problem is that the path "/" in the last routing rule matches every path, because every path starts with a "/". The result is an infinite redirection loop.
I read that path is interpreted as a regular expression, so I tried the pattern "^/$". But this resulted into a PHP error. Then I tried escaping the special regexp symbols "^" and "$", i.e. "\^/\$". But this did not work either.
Include this route last to pick up everything that has fallen through any existing routes. I think that is what you actually want.
Don't remember where I got it from but it does the job.
And you are mistaken about / matching everything. I often have this as my very first route:
It works as expected.
You might want to mess a bit with app/console router:match to see what happens.