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
1 Answer
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?