Use the plus sign “+” instead of dash “-” in URLs

Mark Jaquith uses “+” as the search query string delimiter in his Nice Search Plugin. Here’s what he does:

function cws_nice_search_redirect() {
    if ( is_search() && strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) === false && strpos( $_SERVER['REQUEST_URI'], '/search/' ) === false ) {
        wp_redirect( home_url( '/search/' . str_replace( array( ' ', '%20' ),  array( '+', '+' ), get_query_var( 's' ) ) ) );
        exit();
    }
}

Perhaps it may be of some use for reference?

Leave a Comment