summaryrefslogtreecommitdiffstats
path: root/routers/web/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/web.go')
-rw-r--r--routers/web/web.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/web/web.go b/routers/web/web.go
index 41c4e122fb..ebd0995df8 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -1078,4 +1078,14 @@ func RegisterRoutes(m *web.Route) {
if setting.API.EnableSwagger {
m.Get("/swagger.v1.json", SwaggerV1Json)
}
+ m.NotFound(func(w http.ResponseWriter, req *http.Request) {
+ escapedPath := req.URL.EscapedPath()
+ if len(escapedPath) > 1 && escapedPath[len(escapedPath)-1] == '/' {
+ http.Redirect(w, req, setting.AppSubURL+escapedPath[:len(escapedPath)-1], http.StatusTemporaryRedirect)
+ return
+ }
+ ctx := context.GetContext(req)
+ ctx.NotFound("", nil)
+ })
+
}