Can’t remove front from permalinks for custom taxonomy category page

To get the URL like example.tld/portfolio/PORTFOLIO-CATEGORY-NAME/PORTFOLIO-NAME/ do the following.

Change rewrite for the custom post type to

'rewrite' => array(
    'slug'       => 'portfolio/%portfolio-categorie%',
    'with_front' => false
),

Change rewrite for the custom taxonomy to

'rewrite' => array(
    'with_front' => false
),

Use post_type_link filter to replace %portfolio-categorie% with the actual taxonomy term:

add_filter( 'post_type_link', 'my_portfolio_permalink', 10, 4 );

function my_portfolio_permalink( $post_link, $post, $leavename, $sample ) {
    if ( false !== strpos( $post_link, '%portfolio-categorie%' ) ) {

        $portfolio_cat_term = get_the_terms( $post->ID, 'portfolio-categorie' );

        if ( !empty( $portfolio_cat_term ) ) {
            $post_link = str_replace( '%portfolio-categorie%', array_pop( $portfolio_cat_term )->
        slug, $post_link );
        } else {
            $post_link = str_replace( '%portfolio-categorie%', 'uncategorized', $post_link );
        }
    }
    return $post_link;
}