As usual, rewrite stumped me! I've built a custom search for searching through comments and comment meta, using a flat table. I'm using a rewrite rule as follows:
..../search/reviews/<parameters>
I'm sending a query var 'args' which is group of key/val pairs to search against, to my custom template which has the sql and stuff. This works fine. My problem is, when I search as follows,
.../search/reviews/
Here I'm sending no params, hence I want to either redirect to 404 or just redirect to that same template with args as blank, where I'd see that args is blank and hence show all the results directly. I wrote the rule:
add_rewrite_rule('^search/reviews/','index.php?pagename=search-results','top');
But it still works as default search, searches for the keyword 'reviews' (like WP does for 'hello'.... /search/hello
) and doesn't redirect to my template.
Any help on how to avoid this behavior?