mirror of
https://github.com/golang/go.git
synced 2024-09-30 06:47:04 +00:00
parent
9f17353250
commit
5f484ec118
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user