I am trying to redirect some requests to my website from index.php to another file called admin.php
$page = $_SERVER['REQUEST_URI'];
if ( strpos($page, '?') !== false ) {
$page = strstr($page, '?', true);
}
$page = explode('/', $page);
$page = array_diff($page, ['']);
$page = implode('/', $page);
if ( !$page ) { $page = 'public/home'; }
$file = "pages/{$page}.php";
if ( !is_readable($file) ) {
$file = 'pages/error/404.php';
}
This code selects the page selected from the user. I have this two file using this code but looking in different folders. How do I configure my .htaccess to redirect all the request to www.mysite.com/admin to the file admin.php and all the rest to index.php?