The wp rewrite rule I added to my plugin is not working. Here’s my setup:
Scenario
I’m trying to get the site’s ads.txt to pull from my plugin’s ads.txt. eg site.com/ads.txt pulls from wp-content/plugins/the-plugin/ads.txt – all done via serverside.
Plugin portion
add_action( 'init', 'wpse9870_init_external' );
function wpse9870_init_external()
{
global $wp_rewrite;
$plugin_url = plugins_url( 'ads.txt', __FILE__ );
$plugin_url_sub = substr( $plugin_url, strlen( home_url() ) + 1 );
// flush_rewrite_rules(true); // tried flushh ere
$wp_rewrite->add_external_rule( '^ads.txt$', $plugin_url_sub ); // tried it with and without the caret (^)
// flush_rewrite_rules(true); // also tried flush ere
}
Debug
WP_Rewrite Object {
...
[non_wp_rules] => Array
(
[^ads.txt$] => wp-content/plugins/the-plugin/ads.txt
)
...
}
Going to site.com/ads.txt results in a 404.
What else should I try?