Tagged: ?s=
-
AuthorPosts
-
November 29, 2015 at 8:58 pm #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,
PatrickNovember 30, 2015 at 7:41 am #544308Hi 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,
BasilisJanuary 30, 2017 at 9:42 am #740088Hallo 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 wrongKind regards,
PeterJanuary 30, 2017 at 9:45 am #740090Hi!
After you did that, have you re-flushed your permalinks, from Settings -> Permalinks?
Let us know
Regards,
BasilisJanuary 30, 2017 at 9:57 am #740096Hallo 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,
PeterJanuary 30, 2017 at 9:18 pm #740423Hallo Basilis,
I still need help, because it still does not work
Regards,
PeterFebruary 2, 2017 at 4:50 pm #741893Hallo Basilis,
I put this in robots.txt
User-agent: *
Disallow: /?s=Regards,
Peter
February 2, 2017 at 4:51 pm #741894Hey!
Glad you figurd it out and thank you for sharing your solution! Let us know if you have any other questions or issues!
Cheers!
YigitSeptember 26, 2018 at 4:51 pm #1014867Hello,
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 youSeptember 26, 2018 at 6:08 pm #1014902Hi,
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,
PeterSeptember 27, 2018 at 11:42 am #1015236Hello,
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
September 27, 2018 at 1:36 pm #1015272Hi,
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,
PeterOctober 24, 2019 at 11:13 am #1150839I 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…October 28, 2019 at 10:23 pm #1151916Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.