From 5c3639c1b7efa5d662271f928c2f7f48d3e99683 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sat, 15 Oct 2016 14:21:51 +0100 Subject: [PATCH] Redirect /minio to /minio/ when requests come from browsers (#2937) --- cmd/generic-handlers.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index c5716da0c..d91eccca2 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -80,15 +80,20 @@ func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if !strings.EqualFold(os.Getenv("MINIO_BROWSER"), "off") { // Re-direction handled specifically for browsers. if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && !isRequestSignatureV4(r) { - // '/' is redirected to 'locationPrefix/' - // '/webrpc' is redirected to 'locationPrefix/webrpc' - // '/login' is redirected to 'locationPrefix/login' switch r.URL.Path { case "/", "/webrpc", "/login", "/favicon.ico": + // '/' is redirected to 'locationPrefix/' + // '/webrpc' is redirected to 'locationPrefix/webrpc' + // '/login' is redirected to 'locationPrefix/login' location := h.locationPrefix + r.URL.Path // Redirect to new location. http.Redirect(w, r, location, http.StatusTemporaryRedirect) return + case h.locationPrefix: + // locationPrefix is redirected to 'locationPrefix/' + location := h.locationPrefix + "/" + http.Redirect(w, r, location, http.StatusTemporaryRedirect) + return } } }