Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]+ /(#[^?& ]*)??([^& ]*&)?s=([^& ]+)[^ ]* HTTP/
RewriteRule ^$ http://wordpressblog.com/search/%3? [R=301,L]
Currently I use the above .htaccess mod_rewrite rule to convert default WordPress search permalink:
http://wordpressblog.com/?s=key+word
into nice permalink like this:
http://wordpressblog.com/search/key+word
My question is: What part of the mod_rewrite rule above that I need to change to get a nicer permalink like this one:
http://wordpressblog.com/search/key-word.html
Thanks.
This worked for me. Search wasn’t working when I had permalinks enabled.
Add this JQUERY SCRIPT into your THEME header.php file AFTER wp_head(); tag.
For this to work, you must also have jquery enabled by adding
<?php wp_enqueue_script('jquery'); ?>
in the header.php BEFORE wp_head(); tag.Example:
If I’m thinking right, when you redirect this;
to this;
WordPress will actually search for ‘hello-world.html’, which I doubt you’ll get any results for (presuming ‘hello+world’, where the plus is URL decoded to an actual ‘space’, does return results).
So you’d also need to plug into WordPress before it makes the search, in order to sanitize the search term back to what it was.
Plus it seems a pain to do character replacement in Apache rewrites – you’d have to write a rule for each number of ‘plus’ occurrences.
If I were you, I’d do everything inside WordPress itself, using PHP. I could post a solution if you like the sound of that?