I want to rewrite an url and pass the whole path as a parameter. Something like:
www.example.com/csearch/foo1/bar1/foo2/foo3/bar4 => www.example.com/index.php?page_id=23&csearch=foo1/bar1/foo2/foo3/bar4
The script on page_id 23 will parse the content of csearch.
The path after /csearch/ varies in length. It can have 0 or 30 levels.
I have a working solution for only one level
www.example.com/csearch/foo1 => www.example.com/index.php?page_id=23&filter=foo1
works fine with the following added to functions.php
function create_new_url_querystring() {
add_rewrite_rule('^csearch/([a-zA-Z-]*)/?$', 'index.php?page_id=23&filter=$matches[1]', 'top');
}
add_action('init', 'create_new_url_querystring');
I believe I need a new regex to match the entire path, not only the first level.
Any idea on how to solve my problem?
Thanks.