htaccess redirect for all categories converted to tags now showing 404

Heree’s a code solution, not htaccess. This first checks if current query is for a category page, then checks category existence, and if category not exists but a tag with the same name, it redirects to the tag page.

add_action('parse_request', 'wpse_parse_request');
function wpse_parse_request( $r ){
    if( isset($r->query_vars['category_name']) )
    {
        $cat = get_term_by('slug', $r->query_vars['category_name'], 'category');
        if( !isset($cat->term_id) )
        {
            $tag = get_term_by('slug', $r->query_vars['category_name'], 'post_tag');
            $link = get_term_link($tag);
            if( !is_wp_error($link) )
            {
                wp_redirect($link);
                exit;
            }
        }
    }
}