From a32241e7d31bec7dc6fd1f0b69397e842892007f Mon Sep 17 00:00:00 2001 From: astaxie Date: Sun, 11 Sep 2016 21:27:27 +0800 Subject: [PATCH] fix #2142 --- staticfile.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/staticfile.go b/staticfile.go index 7c8b4517..b7be24f3 100644 --- a/staticfile.go +++ b/staticfile.go @@ -196,9 +196,11 @@ func lookupFile(ctx *context.Context) (bool, string, os.FileInfo, error) { if !fi.IsDir() { return false, fp, fi, err } - ifp := filepath.Join(fp, "index.html") - if ifi, _ := os.Stat(ifp); ifi != nil && ifi.Mode().IsRegular() { - return false, ifp, ifi, err + if requestURL := ctx.Input.URL(); requestURL[len(requestURL)-1] == '/' { + ifp := filepath.Join(fp, "index.html") + if ifi, _ := os.Stat(ifp); ifi != nil && ifi.Mode().IsRegular() { + return false, ifp, ifi, err + } } return !BConfig.WebConfig.DirectoryIndex, fp, fi, err }