From 58d401c3b0b0ab4e3712641f75e217e1a032fa0b Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 27 Jan 2015 00:21:42 -0800 Subject: [PATCH] core/corehttp: gateway_handler: Redirect to path with trailing slash when showing a directory's index.html --- core/corehttp/gateway_handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index dde669c0e..c2c1917b6 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -144,6 +144,11 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { foundIndex := false for _, link := range nd.Links { if link.Name == "index.html" { + if urlPath[len(urlPath)-1] != '/' { + http.Redirect(w, r, urlPath+"/", 302) + return + } + log.Debug("found index") foundIndex = true // return index page instead.