add_rewrite_rule to search

That’s going to the non wp rules because you’re not mapping the URL to the index.php page format.

If you want it to be a WP rule, then you need to start the destination with index.php and include the query string to define what you want the query to contain.

So if you wanted it to go to a specific Page, for example, then you could set it as:

index.php?page=123&name=$matches[0]

WordPress rewrite rules map the “pretty” url formats into the “default” url formats only. They’re not full implementations of the htaccess rewrite system.