I'm trying to add a rewrite rule to Wordpress. I want to rewrite: "http://www.domain.com/plm_check/var_a/var_b/var_c/" to actually use a file from "http://www.domain.com/wp-content/plugins/plm/webservices/plm_check.php?var_a=...&var_b=...&var_c=..."
I've registered it like this:
/* Register rewrites for web service calls */
add_action( 'generate_rewrite_rules' , 'register_plm_rewrites');
function register_plm_rewrites() { //
global $wp_rewrite;
$wp_rewrite->add_external_rule( '^plm_check/([a-zA-z0-9_]+)/([a-zA-z0-9-]+)/([0-9]+)/?$' , PLM_PLUGIN_URL . 'webservices/plm_check.php' );
// Flush the rules
$wp_rewrite->flush_rules();
}
Instead of add_external_rule, I've tried add_rewrite_rule like this:
$wp_rewrite->add_rewrite_rule( '^plm_check/([a-zA-z0-9_]+)/([a-zA-z0-9-]+)/([0-9]+)/?$' , PLM_PLUGIN_URL . 'webservices/plm_check.php' , 'top' );
I've also tried it with and without $wp_rewrite.
I think the problem is that Wordpress won't allow me to directly access that file as a URL. For instance, if I just put in "http://www.domain.com/wp-content/plugins/plm/webservices/plm_check.php", it takes me to the 404 page, even though the file actually exists.
Am I using these functions wrong? Hooking to the wrong action? Trying to do something that WP isn't going to allow?
Thanks!