Created
November 5, 2021 17:41
-
-
Save matdave/6ee7ce8deec10b7b752b2b70eb97eca5 to your computer and use it in GitHub Desktop.
PHP to HTML
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 | |
$base_path = dirname(__FILE__) . '/content/'; | |
if($_GET['q']) { | |
$q = explode('?', $_GET['q']); | |
$file_check = $base_path.preg_replace('"\.html$"', '.php', $q[0]); | |
if (substr($file_check, -1) == "/") { | |
$file_check .= "index.php"; | |
} | |
if (@file_exists($file_check)) { | |
include_once($file_check); | |
} else { | |
http_response_code(404); | |
die(); | |
} | |
} else { | |
http_response_code(404); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment