Rewrite/Prettify search urls on wordpress

I would like to prettify the search URL on my WordPress blog like follow :

someblog.com/?s=some_query ==> someblog.com/search/some_query

Read More

=>This works fine 🙂

someblog.com/?s=some_query&post_type=myview ==> someblog.com/search/myview/some_query

=>Not working right now, the search is made using this “myview/some_query”.

How can I do it ? Preferably only by modifying my .htaccess, any other solution including some php code is welcome as well 😉

Snippet form my .htaccess :

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/?s=([^s]+)&post_type=([^s]+) [NC]
RewriteRule ^ search/%2/%1? [L,R,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/?s=([^s]+) [NC]
RewriteRule ^ search/%1? [L,R,NC]

BR.

Related posts

Leave a Reply