Redirect users from secondary domains to main domain
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user