wordpress add_rewrite_rule not working

I have page on my site named annuaire-membres
and i want this with my custom search like this

example.com/annuaire-membres/character/A

or

Read More
example.com/annuaire-membres/department/xyz

for this I have use the function

function md_custom_taxonomies_rewrite(){    
    add_rewrite_tag('%character%','([^&]+)');
    add_rewrite_tag('%department%','([^&]+)');
    add_rewrite_rule('^annuaire-membres/department/([^/]*)/?','index.php?page_id=27&department=$matches[1]','top');
    add_rewrite_rule('^annuaire-membres/character/([^/]*)/?','index.php?page_id=27&character=$matches[1]','top');   
}
add_action('init','md_custom_taxonomies_rewrite');

but this is not working
any buddy pla help me to solve this

Related posts