[wp-hackers] Rebuild all rewrite rules

Ankur Oberoi aoberoi at gmail.com
Wed Aug 17 01:51:43 UTC 2011

I believe that there are some conflicting and/or invalid rewrite rules (in
$wp_rewrite->rules) on my wordpress site. Is there any way I can force
wordpress to rebuild the rewrite rules?

Also, in a related matter, I would like to add a rule that routes /developer
to /tag/developer for my blog. I understand this is bad from a performance
POV but I still need to be able to do this for my readers (and boss). I
attempted to something like the following:

function tokblog_add_rewrite_rules( $wp_rewrite )
  $new_rules = array( 'developer(.+)$' => 'index.php?tag=developer' );

  //​ Add the new rewrite rule into the top of the global rules array
  $wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);

add_action('generate_rewrite_rules', 'tokblog_add_rewrite_rules');

I'm not sure if this works because like I said before, I think there are
other conflicts in my rewrite rules.

More information about the wp-hackers mailing list