I want to change the search URL from example.com/search/keyword to example.com/result or topic/keyword.

  • By /result, do you mean you always use the URL /result, for any search term, or is result just a placeholder and do you want a search for banana to end up at domain.com/banana?
    – Jan Fabry
    Jul 9, 2011 at 12:04

2 Answers 2


You can change the /search/ part to something else, like /topic/, but it will be harder to remove it completely, since that will conflict with WordPress Pages (is /banana/ a Page with the title "Banana" or is it the result page for the search term "Banana"?).

To change the part, hook into the init action and change the $wp_rewrite->search_base variable:

add_action( 'init', 'wpse21549_init' );
function wpse21549_init()
    $GLOBALS['wp_rewrite']->search_base = 'topic';

You will need to place this snippet of code in your theme's function.php file, or in a new file that you create and that you place in the /wp-content/plugins/ directory. After you did this, visit the Permalinks setting page to flush the rewrite rules.

However, by default when you submit a search you will end up on a URL like ?s=Banana. There are plugins that change this (Ramukar linked to one, but it has the /search/ part hardcoded and has other issues), and Hudson Atwell linked to a simple approach (even too complicated now: you don't need to add the rewrite rule to Apache, as WordPress already contained them since version 1.5).


Just install this plugin, Search Permalink.that's it.you got answer.:)

  • That plugin will change ?s=keyword to /search/keyword, it will not change the search part (it's even hardcoded, so you won't be able to change it to something else).
    – Jan Fabry
    Jul 9, 2011 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.