Subject: | [WISH] redirect if missing trailing / from Catalyst root |
I'm running a Catalyst app at a non-server-root location, say
http://example.com/foo/. When accessing the app root properly with the
trailing slash, Catalyst correctly processes path '/'. However, when
requesting the URL without the slash (like http://example.com/foo)
Catalyst processes path '/foo' instead of '/'.
This is a common problem that can be solved via Apache redirect, but it
would be convenient if Catalyst could solve it by itself. I propose the
following trivial fix, but am unsure where it belongs in the code base:
if ($c->req->uri . '/' eq $c->req->base) {
$c->req->redirect($c->req->base);
return;
}
Perhaps this could even be a plugin that runs at the prepare_path phase?
An incorrect solution would be to internally pretend the URL had the
slash because that would break relative URLs (but you already knew that...).