mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 10:31:29 +00:00
Merge pull request #1792 from youngsterxyf/issue1787
fix issue#1787: if `/m` is a static path mapping to a static dir,and we set `beego.BConfig.WebConfig.DirectoryIndex = true`, then it should redirect to `/m/`
This commit is contained in:
commit
cc2b5f5b62
@ -54,8 +54,13 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if fileInfo.IsDir() {
|
if fileInfo.IsDir() {
|
||||||
|
requestURL := ctx.Input.URL()
|
||||||
|
if requestURL[len(requestURL)-1] != '/' {
|
||||||
|
ctx.Redirect(302, requestURL+"/")
|
||||||
|
} else {
|
||||||
//serveFile will list dir
|
//serveFile will list dir
|
||||||
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
http.ServeFile(ctx.ResponseWriter, ctx.Request, filePath)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user