From: Russ Cox Date: Tue, 24 Nov 2009 19:47:53 +0000 (-0800) Subject: http: redirect to correct URL X-Git-Tag: weekly.2009-12-07~140 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5f484ec118ebcfe752b94a1fbc53026579a8b792;p=gostls13.git http: redirect to correct URL R=r, r1 https://golang.org/cl/157154 --- diff --git a/src/pkg/http/fs.go b/src/pkg/http/fs.go index 55b6f267ed..507ce33a98 100644 --- a/src/pkg/http/fs.go +++ b/src/pkg/http/fs.go @@ -75,10 +75,9 @@ func dirList(c *Conn, f *os.File) { func serveFileInternal(c *Conn, r *Request, name string, redirect bool) { const indexPage = "/index.html"; - // redirect to strip off any index.html - n := len(name) - len(indexPage); - if n >= 0 && name[n:] == indexPage { - Redirect(c, name[0:n+1], StatusMovedPermanently); + // redirect .../index.html to .../ + if strings.HasSuffix(r.URL.Path, indexPage) { + Redirect(c, r.URL.Path[0:len(r.URL.Path)-len(indexPage)+1], StatusMovedPermanently); return; }