title: Rewriting a query string to different directory in wordpress
body: <p>I feel like I've tried everything to get this to work, but my currently-limited knowledge of wordpress may be responsible.</p>
  
  <p>I want to modify part of a query string in a url, so</p>
  
  <p><em>/my_site/wp-admin/admin.php?page=events</em></p>
  
  <p>will redirect to:</p>
  
  <p><em>/my_site/wp-admin/admin.php?page=espresso_events</em></p>
  
  <p>These urls are hard-coded within the plugin, but I want to be able to define my own query string that will point to the url, adding any additional query parameters onto the end.</p>
  
  <pre><code>function plugin_activate()
  {
      global $wp_rewrite;
      $wp_rewrite-&gt;flush_rules();
  }
  function remove_espresso_url()
  {
  
        add_rewrite_rule('page=events&amp;(.*)$', 
                         'wp-admin/admin.php?page=espresso_events&amp;$matches[1]', 
                         'top'
        );
  }
  
  register_activation_hook(__FILE__, 'plugin_activate');
  
  add_action('init', 'remove_espresso_url');
  </code></pre>
  
  <p>The rule is appearing in <code>$wp_rewrite-&gt;non_wp_rules</code>. I've tried various rule variations, and even entirely different rules, but nothing works. I've checked my local server settings and url rewriting is enabled, and my .htaccess file is fine as well.</p>
  
  <p>I've also installed the Monkeyman Rewrite Analyzer plugin, and my rewrite rules aren't appearing in there at all.</p>
  
  <p>Here's the resulting value from <code>wp_rewrite-&gt;mod_rewrite_rules()</code></p>
  
  <pre><code>RewriteEngine On
  RewriteBase /event_espresso/
  RewriteRule ^index\.php$ - [L]
  RewriteRule ^page=events&amp;(.*)$ /event_espresso/wp-admin/admin.php?page=espresso_events&amp;$matches[1] [QSA,L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /event_espresso/index.php [L]
  </code></pre>
  
  <p>Edit: This appears to be because I'm trying to rewrite the query string, however what I need to do is use <code>RewriteCond %{QUERY_STRING}</code>, but I'm not sure Wordpress allows me to add new rewrite conditions.</p>