I need foo-bar to become foo/bar instead:
//domain.com/foo-bar » //domain.com/foo/bar
I'm rebuilding a website that is currently in a home-brew CMS. They have a few pages with children, but the parent page URL does not match the children. The parent URLs were changed but the children were never updated.
Expected Structure:
//domain.com/parent/
//domain.com/parent/child
Current Structure:
//domain.com/parentpage/ (changed from /parent/)
//domain.com/parent/child
I could just create a page for each but I'm trying to avoid having empty/unused pages.
What I'm hoping to do is just create //domain.com/parent-child/ and rewrite the URL to match, but I can't get my rules to take priority over an existing rule.
Maybe I'm misunderstanding what rewrites can accomplish?
add_rewrite_rule
Matched Query:
pagename=foo-bar&page=
My Attempts: I expected somethig like one of these to be my solution, but I've tried a dozen different minor variations without success:
add_rewrite_rule( '^foo/bar', 'index.php?pagename=foo-bar', 'top');
add_rewrite_rule( '(foo)/(bar)', 'index.php?pagename=$matches[1]-$matches[2]&page=', 'top');
Default rule my page is matching:
add_rewrite_rule( '(.?.+?)(?:/([0-9]+))?/?$', 'index.php?pagename=$matches[1]&page=$matches[2]')