Wildcard redirect for WP search queries

#240006
Viewing 2 replies - 1 through 2 (of 2 total)
  • Update: Found a better solution that didn’t need redirection, just used the script below in functions.php to change the search slug:

    function wp_change_search_url() {
    if ( is_search() && ! empty( $_GET[‘s’] ) ) {
    wp_redirect( home_url( “/search/” ) . urlencode( get_query_var( ‘s’ ) ) );
    exit();
    }
    }
    add_action( ‘template_redirect’, ‘wp_change_search_url’ );

    Credit: https://hostpapasupport.com/change-default-search-url-slug-wordpress/

    Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    We are glad it worked for you.

    If you have any other concerns, please don’t hesitate to contact us anytime by creating a new ticket to assist you further with anything else.

    Looking forward to helping you.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘Wildcard redirect for WP search queries’ is closed to new replies.