I’m trying to add a rewrite rule that will point to a file inside a plugin. This can be added in the plugin, theme or .htaccess file.
My current code from inside the theme’s function.php looks like:
// Add Custom Rewrite Rules
function custom_rewrite_basic() {
flush_rewrite_rules();
add_rewrite_rule('^leaf/([0-9]+)/?', 'wp-content/plugins/my-plugin/index.php?leaf=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');
Note: I’m trying to do this on a Multisite network for a path based subdomain.