I produced a wordpress plugin... I personally use my custom variable within this wordpress plugin and I wish to rewrite this url for Search engine optimization, however i can't. Basically make use of the Permalink generator of WordPress, then rewrite is figure, but when I wish to make use of the offical codes during my wordpress plugin for rewrite it does not work.

Here you go an easy code what's not work. I do not no why.

add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
add_filter('query_vars','wp_insertMyRewriteQueryVars');
add_filter('init','flushRules');

// Remember to flush_rules() when adding rules
function flushRules(){
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
}

// Adding a new rule
function wp_insertMyRewriteRules($rules)
{
    $newrules = array();
    $newrules['(project)/(\d*)$'] = 'index.php?pagename=$matches[1]&id=$matches[2]';
    return $newrules + $rules;
}

// Adding the id var so that WP recognizes it
function wp_insertMyRewriteQueryVars($vars)
{
    array_push($vars, 'id');
    return $vars;
}


function search_url_rewrite_rule() {
if ( is_search() && !empty($_GET['s'])) {
wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redirect', 'search_url_rewrite_rule');

I authored a brand new code into my wordpress plugin, however it hasn't effect:

add_action('admin_init', 'flush_rewrite_rules');

add_action('generate_rewrite_rules', 'geotags_add_rewrite_rules');
function geotags_add_rewrite_rules( $wp_rewrite ) 
{
  $new_rules = array( 
     'p/(.+)' => 'index.php?p=' .
       $wp_rewrite->preg_index(1) );

  // Add the new rewrite rule into the top of the global rules array
  $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}

perhaps you have attempted searching only at that page

http://codex.wordpress.org/Class_Reference/WP_Rewrite

and i believe you need to flush the guidelines each time..