ajude a remover a última barra diagonal usando add_rewrite_rule

Eu já tentei de várias maneiras remover a última barra da url que criei com add_rewrite_rule .

abaixo está a implementação do meu código

 function master_load_ads_txt_template_include($template) { $is_load_ads_txt = (bool)get_query_var('ads-txt'); if( $is_load_ads_txt ) { $template = get_template_part("template-parts/ads-txt"); } return $template; } add_action( 'template_include', 'master_load_ads_txt_template_include' ); function master_load_ads_txt_rewrite() { add_rewrite_rule('ads.txt', 'index.php?ads-txt=true', 'top'); add_rewrite_rule('^ads.txt/', 'ads.txt', 'top'); } add_action('init', 'master_load_ads_txt_rewrite'); function master_load_ads_txt_query_vars( $query_vars ) { $query_vars[] = 'ads-txt'; return $query_vars; } add_filter( 'query_vars', 'master_load_ads_txt_query_vars'); 

o código está funcionando, mas não remove a barra ao final da url

insira a descrição da imagem aqui

Solutions Collecting From Web of "ajude a remover a última barra diagonal usando add_rewrite_rule"

 /* ORIGINAL CODE */ function master_load_ads_txt_template_include($template) { $is_load_ads_txt = (bool)get_query_var('ads-txt'); if( $is_load_ads_txt ) { $template = get_template_part("template-parts/ads-txt"); } return $template; } add_action( 'template_include', 'master_load_ads_txt_template_include' ); function master_load_ads_txt_rewrite() { /* UPDATE RULE */ add_rewrite_rule('^ads.txt$', 'index.php?ads-txt=true', 'top'); } add_action('init', 'master_load_ads_txt_rewrite'); function master_load_ads_txt_query_vars( $query_vars ) { $query_vars[] = 'ads-txt'; return $query_vars; } add_filter( 'query_vars', 'master_load_ads_txt_query_vars'); /* ACTION TO ALLOW URL WITHOUT LAST TRAILING SLASH */ function disable_canonical_redirects_for_ads_txt( $redirect_url, $requested_url ) { if ( preg_match( '|ads\.txt|', $requested_url ) ) { return $requested_url; } return $redirect_url; } add_action( 'redirect_canonical', 'disable_canonical_redirects_for_ads_txt', 10, 2 );