Skip to content

Instantly share code, notes, and snippets.

@matdave
Created November 5, 2021 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matdave/6ee7ce8deec10b7b752b2b70eb97eca5 to your computer and use it in GitHub Desktop.
Save matdave/6ee7ce8deec10b7b752b2b70eb97eca5 to your computer and use it in GitHub Desktop.
PHP to HTML
<?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