In my WordPress plugin I have a php file that generates some stats about the blog and outputs it as a simple text file. To access WordPress functions I've included this at the top of the file:
define('WP_USE_THEMES', false); require(dirname(__FILE__) . '/../../../wp-blog-header.php');
Now I'd like to hide the actual URL, since it's in the wp-content/plugins directory and replace it with something nice and short:
http://example.com/wp-content/plugin/data-fetcher/list-data.php -> rewrite to http://example.com/list-data
I added this to
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteRule ^list-data$ wp-content/plugins/data-fetcher/list-data.php [L] </IfModule>
The problem: when I access the short URL, I get a 301 Moved Permanently redirect before I end up on the page. This means that the wp-content/plugins/... URL is revealed in the browser.
I suspect that WordPress is initiating this somehow. The rewrite rule works fine for images and plain php files (i.e. without WP includes/require).
Is my assumption correct? How can I prevent WordPress from sending the redirect?