Viewing 1 replies (of 1 total)
  • mdshak

    (@mdshak)

    Use this custom code at functions.php of child theme.

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

    Now paste this code .htaccess file

    RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
    RewriteRule ^$ /search/%1/? [NC,R,L]
Viewing 1 replies (of 1 total)
  • The topic ‘Custom search url’ is closed to new replies.