Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #544207

    What code does need to be edit in order to remove ?s= from the search result url? So that you will get a clean url.

    Kind regards,
    Patrick

    #544308

    Hi patrickcroonen!

    Please do try the following to your functions.php file

    function 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' );

    and let us know if it works properly

    Best regards,
    Basilis

    #740088

    Hallo Basilis, put the code in functions.php to remove ?s= but i haven the same risult So it does not work with me.
    Do you have any idea what could be wrong

    Kind regards,
    Peter

    #740090

    Hi!

    After you did that, have you re-flushed your permalinks, from Settings -> Permalinks?

    Let us know

    Regards,
    Basilis

    #740096

    Hallo Basilis,

    No, I’ve never heard of it. Do not know how it works So looked it up
    Just hit the save button. But nothing changed.

    Use screaming frog

    Regards,
    Peter

    #740423

    Hallo Basilis,

    I still need help, because it still does not work

    Regards,
    Peter

    #741893

    Hallo Basilis,

    I put this in robots.txt
    User-agent: *
    Disallow: /?s=

    Regards,

    Peter

    #741894

    Hey!

    Glad you figurd it out and thank you for sharing your solution! Let us know if you have any other questions or issues!

    Cheers!
    Yigit

    #1014867

    Hello,
    same problem for me: I detected it using Screaming Frog and I was alerted for duplicate titles, so I discovered duplicated URL with ?s=.

    Most of all come in noindex, but you know noindex still consumes crawl budget, so blocking them by robots.txt would be better, even if removimng them would be the best.

    Well, I tried both function.php and robots.txt edit but they didn’t work.

    Any Idea?
    Thank you

    #1014902

    Hi,

    You can try to add following code to the child theme functions.php – it will add a rel=nofollow attribute to the search icon in the menu

    
    add_filter( 'wp_nav_menu_items', 'avia_append_search_nav', 9997, 2 );
    add_filter( 'avf_fallback_menu_items', 'avia_append_search_nav', 9997, 2 );
    
    function avia_append_search_nav ( $items, $args )
    {	
      if(avia_get_option('header_searchicon','header_searchicon') != "header_searchicon") return $items;
      if(avia_get_option('header_position',  'header_top') != "header_top") return $items;
    
        if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu"))
        {
            global $avia_config;
            ob_start();
            get_search_form();
            $form =  htmlspecialchars(ob_get_clean()) ;
    
            $items .= '
     	<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown menu-item-avia-special">
                <a href="?s=" rel="nofollow" data-avia-search-tooltip="'.$form.'" '.av_icon_string('search').'><span class="avia_hidden_link_text">'.__('Search','avia_framework').'</span></a></li>
    ';
        }
        return $items;
    }
    

    Best regards,
    Peter

    #1015236

    Hello,
    thank you for your reply, but I don’t think adding a nofollow would be a good solution. I think the url with ?s= without search querys should not be generated at all.
    Why adding nofollow/noindex/disallow instead of avoid these error URLs being created?

    Thank you

    #1015272

    Hi,

    Yes but the theme does not generate these urls. It seems like the search engine tries to follow the search link – the href of the link is only “?s=” but the search engine interprets it as a relative url which then results in https://mywebsite.com/?s=

    Best regards,
    Peter

    #1150839

    I have this same problem.

    Enfold is generating an extra URL for each individual page.
    It does so with the search icon code:

    
    <a href="?s=" rel="nofollow" data-avia-search-tooltip="......
    

    Yoast SEO adds a canonical tag to the duplicate URLs, which points to the original URL.
    But yes, this is not very crawl-budget friendly…

    #1151916

    Hi,

    You can block this by adding a no follow at the top of the search page if you want.
    This is our solution, nothing else we can do.

    Best regards,
    Basilis

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.