From 7e060e6e5c1b2807c4fd7dde3b013ce68f617460 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 23 Sep 2014 00:03:47 +0800 Subject: [PATCH] fix the static file dir --- staticfile.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/staticfile.go b/staticfile.go index da511793..a5f6b65c 100644 --- a/staticfile.go +++ b/staticfile.go @@ -68,6 +68,9 @@ func serverStaticRouter(ctx *context.Context) { if finfo.IsDir() && !DirectoryIndex { middleware.Exception("403", ctx.ResponseWriter, ctx.Request, "403 Forbidden") return + } else if ctx.Input.Request.URL.Path[len(ctx.Input.Request.URL.Path)-1] != '/' { + http.Redirect(ctx.ResponseWriter, ctx.Request, ctx.Input.Request.URL.Path+"/", 302) + return } //This block obtained from (https://github.com/smithfox/beego) - it should probably get merged into astaxie/beego after a pull request