From 46f563b5d24bf85b005a402d86c2d52643525de5 Mon Sep 17 00:00:00 2001
From: Massimiliano Adamo <maxadamo@gmail.com>
Date: Sun, 19 Dec 2021 16:14:33 +0100
Subject: [PATCH] fix redirect

---
 main.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go
index a8c25ea..79fc15b 100644
--- a/main.go
+++ b/main.go
@@ -48,8 +48,10 @@ func renderPage(w http.ResponseWriter, req *http.Request) {
 }
 
 // function redirect
-func redirect(w http.ResponseWriter, r *http.Request) {
-	http.Redirect(w, r, "/by_name.html", http.StatusMovedPermanently)
+func redirect(w http.ResponseWriter, req *http.Request) {
+	redirectURL := filepath.Join(req.URL.Path, "/by_name.html")
+	fmt.Printf("test %s\n", redirectURL)
+	http.Redirect(w, req, redirectURL, http.StatusMovedPermanently)
 }
 
 func main() {
-- 
GitLab