How do i change the url of wordpress search results?

by default wordpress search results go to sitename.com/?s=terms but i would like it be changes to sitename.com/search/?s=terms

I have tried using the

Read More
fb_change_search_url_rewrite() {
  if ( is_search() && ! empty( $_GET['s'] ) ) {
    wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
    exit();
  } 
}
add_action( 'template_redirect', 'fb_change_search_url_rewrite' );

This get close as now when you do search it goes to search/searchterm but does not have the ?s= in the url

Related posts

Leave a Reply

1 comment