Query vars to return the homepage
I would like to rewrite a path like example.com/foo to the front page (example.com).
So when I request example.com/foo the content shown should be that of example.com. Note, a redirect is NOT what I am looking for here.
I am trying to do this with the add_rewrite_rule() function but cant find the query vars to get the homepage
add_action( 'init', function() {
add_rewrite_rule(
'^foo/?$',
'index.php?pagename=homepage',
'top'
);
});
I also tried index.php?pagename=/, index.php?page=front, index.php (no query vars) and a bunch of other combinations.
I just cant seem to find the query var to tell Wordpress to load the homepage.
Topic query-variable url-rewriting Wordpress
Category Web