redirects for removed/deleted woocommerce products

You can actually use PHP to make redirects, rather than just .htaccess, which has the benefit of allowing you to use variables.

I don’t really know woocommerce too well but you could create a redirect similar to this.

Note this is pseudo code. These function calls are fictional but the logic
will still apply

function redirect_product() {

    $product_status = get_product(); 

    $product_url = get_product_url();  

    if ($product_status === NULL) {

       $URL = $_SERVER['REQUEST_URI'];
       if ( $URL == $product_url) {
         header( 'HTTP/1.0 301 Moved Permanently' );
         header( 'Location: /' ); //redirect to url of your choosing
         exit();
       } else {
         return;
       }
    }
}

error code: 523