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 created page "play" url: http://localhost/myweb/play and inside of page "play" I include PHP code to make the new search from outside Wordpress.

And all worked, if I search from my page "play" the url will be: http://localhost/myweb/play?m=text+Search&pageno=1

Now, I want my search result url to be fancy url, like: http://localhost/myweb/play_text_Search_1.html

I have tried several add_rewrite_rules but not worked, return "404 not found":

add_action('generate_rewrite_rules', 'add_rewrite_rules');
function add_rewrite_rules( $wp_rewrite ) 
{
    add_rewrite_rule('^^([^-]*)_([^-]*)\.html$ play&m=$1&pageno=$2[1]', 'top');
    flush_rewrite_rules(false);
}

ps: sorry my english is not good

share|improve this question
    
start by reading the codex page for add_rewrite_rule and search this site for other questions using add_rewrite_rule, your rule arguments are incorrect. the format you want to rewrite to is very strange, why the .html extension? something like /play/search-string/1/ makes much more sense to me. –  Milo Jan 24 '13 at 22:03

1 Answer 1

up vote 0 down vote accepted

Only way I knowit to do this it's using this function:

/*
 * Redirects search results from /?s=query to /search/query/, converts %20 to +
 * @link http://txfx.net/wordpress-plugins/nice-search/
 * =======================================  */
function search_redirect() {
  if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/find/') === false) {
    wp_redirect(home_url('/finde/' . str_replace(array(' ', '%20'), array('+', '+'), urlencode(get_query_var('s')))), 301);
    exit();
  }
}
add_action('template_redirect', 'search_redirect');

It's this you wanna do?

share|improve this answer
    
Beneti: Thanks for your answer.i dont use wordpress search, i created new custom search page who searching to outside wordpress (no wordpress database query). thanks rick. –  dimsdims Jan 24 '13 at 18:21
    
@beneti: i got sulution from your answer. thanks –  dimsdims Feb 3 '13 at 1:43

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.