diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 1fb081c..8d2bc78 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -211,13 +211,12 @@ 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 - switch r.Host { - case "www.pixeldrain.com", - "pixeldrain.net", "www.pixeldrain.net", - "pixeldra.in", "www.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) + if strings.HasPrefix(r.Host, "www.") { + http.Redirect( + w, r, + "https://"+strings.TrimPrefix(r.Host, "www.")+r.URL.String(), + http.StatusMovedPermanently, + ) return }