WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found this snippet online …

function search_url_rewrite_rule() {
    if ( is_search() && !empty($_GET['s'])) {
        wp_redirect(home_url("/search/") . urlencode(get_query_var('s')));

add_action('template_redirect', 'search_url_rewrite_rule');

This transforms my ?/s=term into /search/term which is almost what I want. I'd like to use the german word "suche" instead of "search" inside my permalinks.

I thought of changing home_url("/search/") to simply home_url("/suche/") but that doesn't work.

How can I make that happen?

share|improve this question
up vote 2 down vote accepted

The reason it isn't working is because you haven't told WordPress how to handle that page. You can do so by applying a rewrite rule in the following manner.

add_action( 'init', 'wpse_63716_search_rule' );
function wpse_63716_search_rule(){
    add_rewrite_rule('^suche/([^/]*)?', 'index.php?s=$matches[1]', 'top');

Don't forget to flush the permalinks after adding the above code.

share|improve this answer

Your Answer


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.