Here are some notes.
- Install Toschos rewrite plugin
- Install Jan Fabrys rewrite analyzer plugin.
- Use the Rewrite API
- Add your rules to
top
.
There’s also the function add_external_rule()
, which should be accessible via
$GLOBALS['wp_rewrite']->add_external_rule();
All your external rules are accessible via $wp_rewrite->non_wp_rules
. Here’re the internals, that show you how the rules get added inside $wp_rewrite->mod_rewrite_rules()
:
// add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
foreach ( (array) $this->non_wp_rules as $match => $query) {
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
$match = str_replace('.+?', '.+', $match);
// If the match is unanchored and greedy, prepend rewrite conditions
// to avoid infinite redirects and eclipsing of real files.
//if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
//nada.
//}
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
}
The phpDocBlock for that method states the following
Retrieve
mod_rewrite
formatted rewrite rules to write to.htaccess.
Does not actually write to the
.htaccess
file, but creates the rules for the process that will.Will add the non_wp_rules property rules to the
.htaccess
file before the WordPress rewrite rules one.