diff --git a/templates/vhost.conf.j2 b/templates/vhost.conf.j2
index 2a6872b1afe5dbc0f9a1ebba43431218e2d50664..ece2cf9b4c82c960e8129b8c4ca982b1295bc1cb 100644
--- a/templates/vhost.conf.j2
+++ b/templates/vhost.conf.j2
@@ -89,7 +89,7 @@ server {
 
 	{% if vhost.disallow_dotfiles %}
 	# explicitly allow .well-known/
-	location ~ /\.well-known/ {
+	location ~ ^/\.well-known/ {
 		allow all;
 	}