diff --git a/main/pbx.c b/main/pbx.c
index 039d7beb3a6be37a43a1861a11d9673fc7773ec3..ac88d5a01a756a86c623f77c07d32e411c50a04f 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -736,11 +736,12 @@ enum ext_match_t {
  *	E_MATCHMORE	success only on partial match (i.e. leftover digits in pattern)
  *	E_CANMATCH	either of the above.
  */
+
 static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
 {
 	mode &= E_MATCH_MASK;	/* only consider the relevant bits */
-	
-	if (!strcasecmp(pattern,data)) /* note: if this test is left out, then _x. will not match _x. !!! */
+
+	if (mode == E_MATCH && pattern[0] == '_' && strcasecmp(pattern,data)==0) /* note: if this test is left out, then _x. will not match _x. !!! */
 		return 1;
 
 	if (pattern[0] != '_') { /* not a pattern, try exact or partial match */