尝试将rewrite_rule添加到query_vars

I am trying to add rewrite rule to query_vars but it is not working. currently the permalink is looking like this:

localhost/mysite/?detail=value

but i want it to look like this:

localhost/mysite/value

here is my code:

add_filter('query_vars', 'do_queryvars' );
function do_queryvars( $qvars ) {
$qvars[] = 'detail';
return $qvars;
}

function do_rewrite_rules($rules) {
    $new_rules = array('detail/([^/]+)/?$' => 'index.php?detail=$matches[1]');
    $rules = $new_rules + $rules;
    return $rules;
}
add_filter('rewrite_rules_array', 'do_rewrite_rules'); 

link:

<a href="?detail=<?php echo $value; ?>" >Link</a>

Based on your Rewrite Rule function, you should call your link like this

http://localhost/mysite/detail/value