about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-12-04 19:59:33 +0100
committerAlan Pearce2024-12-04 19:59:33 +0100
commit8f536a3b6a915cfb2f2fff909d52ba7354b6315a (patch)
tree7cf98b8c552f22fb84655d38d69e4666b855fab9
parent60dbf7194e15c8ffafb530769611396ac361640e (diff)
downloadwebsite-8f536a3b6a915cfb2f2fff909d52ba7354b6315a.tar.lz
website-8f536a3b6a915cfb2f2fff909d52ba7354b6315a.tar.zst
website-8f536a3b6a915cfb2f2fff909d52ba7354b6315a.zip
server: 404 if host not recognised
-rw-r--r--internal/server/server.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index b327f3d..ba825aa 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -194,10 +194,12 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) {
 				path, _ := website.CanonicalisePath(r.URL.Path)
 				newURL := config.BaseURL.JoinPath(path)
 				http.Redirect(w, r, newURL.String(), http.StatusMovedPermanently)
-			} else {
+			} else if re.MatchString(r.Host) {
 				url := config.BaseURL
 				url.Host = re.ReplaceAllString(r.Host, replace)
 				http.Redirect(w, r, url.String(), http.StatusTemporaryRedirect)
+			} else {
+				http.NotFound(w, r)
 			}
 		})
 	} else {