mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 08:50:56 +00:00
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/
This commit is contained in:
parent
d90195061f
commit
9aa2e5b575
@ -54,8 +54,13 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if fileInfo.IsDir() {
|
if fileInfo.IsDir() {
|
||||||
//serveFile will list dir
|
requestURL := ctx.Input.URL()
|
||||||
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
if requestURL[len(requestURL)-1] != '/' {
|
||||||
|
ctx.Redirect(302, requestURL+"/")
|
||||||
|
} else {
|
||||||
|
//serveFile will list dir
|
||||||
|
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user