There are many takes at that. And the most suggested one is to use a ready-made framework. But assuming this code as is: First of all, I don't see the real need for this router. Why not to request login.php directly and inside it include tpl/login.tpl.php? If you want to hide the .php extension (though not sure why), it's also possible with a simple .htaccess rule. Speaking of the code itself ### Simplifying the code We can remove the extra nesting and duplication <?php $page = $_GET['page'] ?? 'home'; switch ($page) { case 'login': require 'inc/login.php'; include 'tpl/login.tpl.php'; break; case 'logout': require 'inc/logout.php'; include 'tpl/logout.tpl.php'; break; case 'home': require 'inc/home.php'; include 'tpl/home.tpl.php'; break; default: http_response_code(404); } I must note that checking for empty($_GET) is essentially useless because we are inside a condition that already made sure that $_GET is not empty. Now we can't help but notice the pattern, and every pattern in the code must be deflated, by means of a loop or similar measure. Here we will use some string/array tricks ```php $pages = ['login', 'logout', 'home']; $page = $_GET['page'] ?? 'home'; if (in_array($page, $pages)) { require "inc/$page.php"; include "tpl/$page.tpl.php"; } else { http_response_code(404); } ``` ### Making it extensible What I don't like about this code is that it's static. It can serve only three pages. You'd have to add another branch/array item for the every page. Not very convenient. Why not to make it automatic? ```php $page = $_GET['page'] ?? 'home'; if (file_exists("inc/$page.php")) { require "inc/$page.php"; include "tpl/$page.tpl.php"; } else { http_response_code(404); } ``` Now you will only have to add a new file to inc folder and it will be served as well ### Adhering to HTTP standards HTTP status codes are not for decoration. They must be used in the exact situations they are intended for. When a page is not found, your server should respond with 404 status, not 302. I would advise to create designated pages in the inc directory and include them along with setting appropriate HTTP status.