diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 2b6604ad02de8ca5820af353f97520bc6b33ed28..707db09c52b64236b1da3615c5fd0602ab19d855 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -220,7 +220,7 @@ class Module
             throw new Error\NotFound('The URL wasn\'t found in the module.');
         }
 
-        if (preg_match('#\.php$#D', $path)) {
+        if (substr($path, -4) === '.php') {
             // PHP file - attempt to run it
 
             /* In some environments, $_SERVER['SCRIPT_NAME'] is already set with $_SERVER['PATH_INFO']. Check for that