Last active
April 21, 2020 08:38
-
-
Save bshaffer/d752d8c437f26dd0735fcff91ba9d7dc to your computer and use it in GitHub Desktop.
Example PHP CGI-style front controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Static list provides security against URL injection by default. | |
switch (@parse_url($_SERVER['REQUEST_URI'])['path']) { | |
case '/': | |
require 'homepage.php'; | |
break; | |
case 'admin.php': | |
require 'admin.php'; | |
break; | |
default: | |
http_response_code(404); | |
exit('Not Found'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment