更改wordpress搜索网址

this is the code wich Im trying

function search_url_rewrite() {
    if ( is_search() && ! empty( $_GET['s'] ) ) {
        global $opt; if($opt['rewrite_slug_search']){ $search_url = $opt['rewrite_slug_search']; 
        } else { $search_url = 'search'; }
        wp_redirect( home_url( $search_url ) . urlencode( get_query_var( 's' ) ) );
        exit();
    }   
}
add_action( 'template_redirect', 'search_url_rewrite' );

the $search_url is option from my theme settings panel but there is a problem with the slash when I type test in search box I get searchtest instead of search/test do you have any idea how to get a slash between?