php如果变量匹配dir unset变量

I want to protect pages from the actual path so I'm using the server uri variable to know what the user write in the nav bar:

page.php

if ($_SERVER['REQUEST_URI'] == '/path/to/page.php') {
    unset($_SERVER['REQUEST_URI']); // nothing will be displayed
} else // page content

And it's working fine, but now the problem is ?id=x or just adding ? will show the page with errors.

Is there a way to add OR == ?....

I want to prevent the direct access, because I'm using a router that includes those pages in index.php like this: site.com/page and site.com/page?...

Thank YOU!

EDIT: Add more info:

.htaccess

Options -Indexes

DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

the router in index.php

// array whitelist for match
$includes = array(
    '/home'    => 'dir/to/home.php',
    '/other'    => 'dir/to/other/page.php'
);
if ($_SERVER['REQUEST_URI'] == '/')
    $_SERVER['REQUEST_URI'] = '/home';

preg_match('/^([\w\/]+)/', $_SERVER['REQUEST_URI'], $matches);
$matches[1] = isset($matches[1]) ? $matches[1] : null;

if(array_key_exists($matches[1], $includes)) {
    $content = include($includes[$matches[1]]); 
} else $content = include('views/error.php');
return $content;

I don't know if I understand, but if you do this way:

if (preg_match('\/path\/to\/page\.php', $_SERVER['REQUEST_URI'] ))