if ($_SERVER['REQUEST_URI'] == '/')
$page = 'home';
else
$page = substr($_SERVER['REQUEST_URI'], 1);
session_start();
include 'config.php';
if (file_exists("all/$page.php"))
include "all/$page.php";
else if ($_SESSION['user'] and file_exists("auth/$page.php"))
include "auth/$page.php";
else if (!$_SESSION['user']['id'] and file_exists("guest/$page.php"))
include "guest/$page.php";
else
exit('Страница не найдена.');
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]