I’ve recently had to set up some redirects using Laravel 4.2 that had a trailing slash… if you’ve ever had to do this on Laravel then you know it isn’t as straightforward as the rest of the framework is.

Normally when writing a redirect to a URL outside of my application but inside of my domain I’ll do this and it works fine:

Redirect::to('example/page', 301);

When redirecting to a page that requires a trailing slash:

Redirect::to('example/page/', 301);

Laravel strips the trailing slash and just sends me to example/page instead of example/page/. I had even tried this:

Redirect::to('example/page' . '/', 301);

My solution is to use the following:

Redirect::to('example/page' . '\/', 301);

The solution isn’t very elegant but it gets the job done.