views:

17

answers:

1
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.

A: 

If I'm thinking right, when you redirect this;

?s=hello+world

to this;

/search/hello-world.html

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?

TheDeadMedic
sure, any kind of solution is welcome. thanks.
poer