Removing rules from .htaccess
Problem 1 Your hook ci_add_rules() will still run when you flush rules, so remove it first (and avoid “unsetting” non_wp_rules, you’ll break other plugins that make use of it). function ci_remove_rules() { remove_action( ‘generate_rewrite_rules’, ‘ci_add_rules’ ); $GLOBALS[‘wp_rewrite’]->flush_rules(); } Problem 2 Pretty sure you want: plugin_dir_url( ‘proxy.php’, __FILE__ ) ..instead of: plugin_dir_path( __FILE__ ) . ‘proxy.php