Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to chang my custom search url for SEO purpose. I found an article about how to change to However, i prefer to have a custom search url such as

Is this achievable?

Thank you for any help!

share|improve this question

migrated from Jun 11 '12 at 13:47

This question came from our site for professional and enthusiast programmers.

What article did you find to achieve that URL? please post a link and code. I would guess you can just change search to something. – Milo Jun 11 '12 at 14:38

1 Answer 1

up vote 1 down vote accepted

It's easy. Just add this hook for template_redirect action and it will redirect your search queries to nice url:

function wpse8170_search_url_redirect() {
    if ( is_search() && !empty( $_GET['s'] ) ) {
        wp_redirect( home_url( "/something/" . urlencode( get_query_var( 's' ) ) ) );
add_action( 'template_redirect', 'wpse8170_search_url_redirect' );

Add to your .htaccess file:

# search redirect
# this will take anything in the query string, minus any extraneous values, and turn them into a clean working url
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]
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.