I created a page template to serve information dynamically.

For url like

example.com/the-hamptons => index.php?page\_id=92&filter=the-hamptons

For url like

example.com/page-that-exists <- show page

Basically, if the url points to a page that exists, show the page. If the page does not exist, pass everything after the / to the page template in variable 'filter'.

I added the following to functions.php in my child theme.

```
function add_query_vars($aVars) {
    $aVars[] = "filter";
    return $aVars;
}

// hook add_query_vars function into query_vars
add_filter('query_vars', 'add_query_vars');

```

and

```
function add_rewrite_rules($aRules) {
    $aNewRules = array('/([^/]+)/?$' => 'index.php?page_id=92&filter=matches[1]');
    $aRules = $aNewRules + $aRules;
    return $aRules;
}

// hook add_rewrite_rules function into rewrite_rules_array
add_filter('rewrite_rules_array', 'add_rewrite_rules');

```

I get a page not found when I type a url that does not exist.

If type a url that exists, it shows the correct page in that url.

Thank you for the help.