Skip to main content
edited title
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

rewriting search-permalink with htaccess - Rewriting search results are are "opened" automatically?permalink

Source Link
mathiregister
  • 1.5k
  • 13
  • 55
  • 78

rewriting search-permalink with htaccess - search results are are "opened" automatically?

when typing "a" into my search field (/?s=a) I my search.php template is loaded and all results that match that letter are shown.

If I add this to my .htacess …

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^s=(.+)$
RewriteRule .* /searchmyblog/%1/? [R,L]

and then type "a" into my search the first result of my search is shown. So there is no search.php template shown with all the results but rather the page is redirected to "mypage.com/somecategory/amore-mio"

Why is that happening? I simply want to rewrite the normal /?s= to /search/ or any other custom url.

Any ideas on that? I found heaps of posts online, but none of them seem to be state of the art or use some weird JS-hacks that I find unnecessary.

Ideas on that?