Commit 5f484ec1 authored by Russ Cox's avatar Russ Cox

http: redirect to correct URL

R=r, r1
https://golang.org/cl/157154
parent 9f173532
...@@ -75,10 +75,9 @@ func dirList(c *Conn, f *os.File) { ...@@ -75,10 +75,9 @@ func dirList(c *Conn, f *os.File) {
func serveFileInternal(c *Conn, r *Request, name string, redirect bool) { func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
const indexPage = "/index.html"; const indexPage = "/index.html";
// redirect to strip off any index.html // redirect .../index.html to .../
n := len(name) - len(indexPage); if strings.HasSuffix(r.URL.Path, indexPage) {
if n >= 0 && name[n:] == indexPage { Redirect(c, r.URL.Path[0:len(r.URL.Path)-len(indexPage)+1], StatusMovedPermanently);
Redirect(c, name[0:n+1], StatusMovedPermanently);
return; 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