add_rewrite_rule fro html to another url not working

Or you could just add the relevant directive to the top of the .htaccess file directly. For example:

RewriteRule ^([^/]+)\.html$ /product/$1 [R=302,L]

This matches /anyname.html (as in your example), but not /foo/bar/anyname.html.