diff --git a/templates/vhost.conf b/templates/vhost.conf
index 86b72ec6cb95a1f40688f6930a11173c31db8ef6..aeeae55c22f50eb45702998c29ac8b95d6b054e5 100644
--- a/templates/vhost.conf
+++ b/templates/vhost.conf
@@ -31,7 +31,13 @@
   Header always add Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
 
 {% if matomo.jail is defined and not php_fpm_socket|default(false) %}
-  ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:{{ matomo.jail.port }}/$1
+  <LocationMatch "/fpm-status">
+    Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf
+    ProxyPass fcgi://127.0.0.1:{{ matomo.jail.port }}
+  </LocationMatch>
+  <FilesMatch \.php$>
+    SetHandler "proxy:fcgi://127.0.0.1:{{ matomo.jail.port }}"
+  </FilesMatch>
 {% endif %}
 
   DocumentRoot {{ webRoot }}