url rewriting – add_rewrite_rule fro html to another url not working

I want to redirect mywebsite.com/anyname.html to mywebsite.com/product/anyname For that I write the following query in functions.php . But it is not working . Please see my code below

function custom_rewrite_basic() {
  add_rewrite_rule('^(.*).html$', '/product/$1');
}

add_action('init', 'custom_rewrite_basic');

Please help to solve the issue.