From 1339c85fee32f63d2d25ed2e86199e0f555fb6a1 Mon Sep 17 00:00:00 2001 From: Fornax Date: Thu, 14 Sep 2023 16:59:46 +0200 Subject: [PATCH] Redirect users from secondary domains to main domain --- webcontroller/web_controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 7a09cb4..2eab0fe 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -221,6 +221,14 @@ func New(r *httprouter.Router, prefix string, conf Config) (wc *WebController) { func middleware(handle httprouter.Handle) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + // Redirect the user to the correct domain + if r.Host == "pixeldrain.net" || r.Host == "pixeldra.in" { + var target = "https://pixeldrain.com" + r.URL.String() + log.Debug("Redirecting user from '%s' to '%s'", r.URL.String(), target) + http.Redirect(w, r, target, http.StatusMovedPermanently) + return + } + w.Header().Set("Strict-Transport-Security", "max-age=31536000") w.Header().Set("X-Clacks-Overhead", "GNU Terry Pratchett") handle(w, r, p)