Commit 9aa2e5b5 authored by youngsterxyf's avatar youngsterxyf

fix issue#1787: The cause is that if the url is /m,and we set…

fix issue#1787: The cause is that if the url is /m,and we set beego.BConfig.WebConfig.DirectoryIndex = true, then it should redirect to /m/
parent d9019506
......@@ -54,8 +54,13 @@ func serverStaticRouter(ctx *context.Context) {
return
}
if fileInfo.IsDir() {
//serveFile will list dir
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
requestURL := ctx.Input.URL()
if requestURL[len(requestURL)-1] != '/' {
ctx.Redirect(302, requestURL+"/")
} else {
//serveFile will list dir
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
}
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment