Use PHP to host multiple domains with different HTML content

|| Taken from the NodeHost community, posted by Dalton Edwards before shutdown

For starters you need to setup your .htaccess file (in root directory)!

RewriteEngine On
RewriteRule ^(.*)$ index.php?query=$1 [QSA,NS]

Inside root directory create a file called index.php and put this inside of it:

function include_page($host, $query)
$host  = $_SERVER["HTTP_HOST"];
$query = $_GET["query"];
if (!empty($query)) {
    if (file_exists("$host/$query")) {
        $file_info = new finfo(FILEINFO_MIME_TYPE);
        $mime_type = $file_info->buffer(file_get_contents("$host/$query"));
        header("Content-type: $mime_type");
    } else if (file_exists("$host/pages/" . strtolower($query) . ".html")) {
        include_page($host, strtolower($query));
    } else {
        if (file_exists("$host/pages/404.html")) {
            include_page($host, "404");
        } else {
            header("Content-type: text/plain;charset=utf-8");
            echo "pages/404.html not found";
} else {
    if (file_exists("$host/pages/home.html")) {
        include_page($host, "home");
    } else {
        header("Content-type: text/plain;charset=utf-8");
        echo "pages/home.html not found";

Now inside root directory create new directories for every one of your domains (and make sure they are added as aliases in your NodeHost settings).

For example my root directory looks like:

Inside domain directory create two more directories called pages and layout.

Page names should be in all lowercase (pages/pagename.html) is accessible at (case insensitive).

Create pages/home.html and put your home content in it!! This is the page that shows when no page is defined.

In layout directory create header.html and footer.html.

This is from my specific setup. You can edit this to work however you want.

If a page doesn't exist it'll check to see if it's a file (and in most cases add the correct content-type header).