I need Wordpress to redirect requests matching a specific url structure to another script than index.php.
I'm using nginx so i cannot simply add a rewrite rule in the .htaccess file nor do I have access to the server configuration file. So I guess my only option is to do it from within WordPress.
I tried the following, then saved the Settings>Permalinks to flush the rewrite rules, but it does not work.
function rewrite_action() {
add_rewrite_tag('%template%', '([^/]*)');
add_rewrite_tag('%title%', '([^/]*)');
add_rewrite_rule( '^partners/([^/]*)/?', 'partners-output.php?template=$matches[1]', 'top');
add_rewrite_rule( '^partners/([^/]*)/([^/]*)$?', 'partners-output.php?template=$matches[1]&title=$matches[2]', 'top');
}
add_action( 'init', __NAMESPACE__ . '\rewrite_action', 1, 0 );
Right now, it only returns WordPress's 404 page.