From 19e1e4cc1c23772f691e73ecf7602348a81e83f8 Mon Sep 17 00:00:00 2001 From: Pacien Date: Thu, 11 Jul 2013 16:32:52 +0200 Subject: Add trailing slash to URLs (dynamic mode) --- dynamic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dynamic.go b/dynamic.go index 9df04b9..e2a2713 100644 --- a/dynamic.go +++ b/dynamic.go @@ -34,6 +34,12 @@ func handle(w http.ResponseWriter, r *http.Request) { return } + // redirect to add the trailing slash if missing + if !strings.HasSuffix(r.URL.Path, "/") { + http.Redirect(w, r, r.URL.Path+"/", http.StatusFound) + return + } + // get the list of dirs to parse request := strings.TrimSuffix(r.URL.Path, "/") dirs := strings.Split(request, "/") -- cgit v1.2.3