2

I have a multisite install of WordPress. I have installed the plugin Monkeyman Rewrite Analyzer so I can see all the rules I have registered. The code below is how I am registering the rule:

 add_action( 'init', 'add_init_rules' );

 function add_init_rules() {
     add_rewrite_rule('^car/([^/]*)/([^/]*)/?','index.php?pagename=car&id=$matches[1]&make=$matches[2]','top');
 }

The rule I have added does not appear in the Monkeyman Rewrite Analyzer list and does not appear to make any difference to the site when trying to visit mysite.com/32423/testmake

Any suggestions?

2 Answers 2

0

Did you flush the rules after making this code?

Visit the Settings->Permalinks screen. This will cause a rule flush. Then check and see if your new rule appears.

2
  • Thanks, can't believe all the WordPress documentation doesn't mention this. Do you know why it appears like this in the plugin? oi62.tinypic.com/2n6b2ht.jpg
    – Alex
    May 14, 2014 at 12:58
  • Possibly the plugin doesn't think that "id" and "make" are Query Variables. So they won't go into the $wp_query instance.
    – Otto
    May 14, 2014 at 17:01
0

The rule you added is a "non wp rule", that is, a rule added to htaccess. Sadly, with multisite these rules get completely ignored and don't get written to your htaccess. WordPress uses hardcoded htaccess rules when multisite is enabled. I've struggled with this myself and haven't found any solution yet (except editing htaccess directly).

2
  • No, his rule starts with index.php, making it a WP rule.
    – Otto
    May 14, 2014 at 17:01
  • Oh, I missed that, you're right. Guess I still was a bit too focused on my own rewrite issues and too quick to answer.
    – Björn
    May 14, 2014 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.