custom url rewrite

Your rewriterule should be:

add_rewrite_rule('^directory/view/(.+)/(\d+)/', 'index.php?pagename=directory/view&search=$matches[1]&number=$matches[2]', 'top');

Remember to flush your rewriterules after every edit (go to settings > permalinks).


EDIT added complete code example.

function add_directory_rewrite() {
    add_rewrite_tag("%search%", '(.+)');
    add_rewrite_tag("%number%", '(\d+)');
    add_rewrite_rule('^directory/view/(.+)/(\d+)', 'index.php?pagename=directory/view&search=$matches[1]&number=$matches[2]', 'top');
}
add_action( 'init', 'add_directory_rewrite' );

In page.php for testing purposes:

<?php echo get_query_var("search"); echo get_query_var("number"); ?>

This worked on my own site, even changed the blog url to /blog/ to test the structure.

If this still doesn’t work, maybe empty your htaccess an save it in settings > permalinks again (make sure the file is writable).

Removed trailing slash from '^directory/view/(.+)/(\d+)/' and it works.

techhipbettruvabetnorabahisbahis forumuedusedusedusedueduedueduedueduedu