Laravel splat routes
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Recently I had to change one of the slugs for a model on a site I was working on. Because the pages under that model would have had a lot of inbound links we wanted to do a 301 redirect to the new slug. Here's the route I added which I thought would do the trick.
However, while this would work for anything one directory under the slug it wouldn't work for anything more nested than that. For example:
umelb/subjects
would 301 redirect tounimelb/subjects
, however;umelb/subjects/mdia1001
would 404 instead.
The fix to this is to let the route know that the splat can literally be any character, so that it will encompass every route underneath.