Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
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 '11 at 12:04

3 Answers 3

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).

share|improve this answer

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

share|improve this 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 '11 at 11:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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