Rewrite rules for new plugin
-
Hi,
I realise this kind of question has been asked several times, but I have read all of the posts I can find here and on the interweb, and I am still stumped. What I want to do is write a plugin and map URLs onto PHP scripts in the plugin’s directory. Say the plugin is called ‘foo’, I would want to set up rules to map:
/foo/ => /wp-content/plugins/foo/main.php
/foo/bar/ => /wp-content/plugins/foo/bar.php
/foo/baz/ => /wp-content/plugins/foo/baz.phpAnd so on. With WP1.5 I would have written some RewriteRules for .htaccess, something along the lines of:
RewriteRule ^foo/bar/(.*)$ /wp-content/plugins/foo/bar.php?uri=$1 [QSA,L]
RewriteRule ^foo/baz/(.*)$ /wp-content/plugins/foo/baz.php?uri=$1 [QSA,L]
RewriteRule ^foo/$ /wp-content/plugins/foo/main.php [QSA,L](NB: I just made these up so they may be wrong, but you get the idea …)
It looks like I should be able to do this programmatically in WP2.0 but I can never get anything to work, no matter what filters / hooks I try to use. I have tried copying the method that Ultimate Tag Warrior uses but I cannot even get UTW to redirect properly (version 2.9.1 on a fresh install of WP2.0 – but that is another issue).
What should I be doing? The fact that UTW does not work makes me think that there might be a deeper problem with redirects in WP2.0.
Cheers,
David
- The topic ‘Rewrite rules for new plugin’ is closed to new replies.