First thing to check is make sure you visit permalinks page, or call the flush_rewrite_rules
function once after you call add_rewrite_rules otherwise the rule will not get applied.
So to restate your question, is it correct that you’re trying to achieve rewriting this:
example.com/project-centers/kitchen/x/y/z
To this:
eample.com/index.php?pagename=kitchen&var1=x&var2=y&var3=z
If that’s correct, your code looks like it should work, but if it’s not you should try writing your rewrite rule like this:
add_rewrite_rule(
'^project-centers/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$',
'index.php?pagename=$matches[1]&var1=$matches[2]&var2=$matches[3]&var3=$matches[4]',
'top'
);
This change is to make it clear to the regex that it should never match a /
inside any of the matched strings, otherwise it can easily do this and things get complicated.
Remember to either visit the permalinks page, or call the flush_rewrite_rules
function once (not on every page load) after you call add_rewrite_rules otherwise the rule will not get applied!
Let me know if that helps