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:

<?php
function include_page($host, $query)
{
include("$host/layout/header.html");
include("$host/pages/$query.html");
include("$host/layout/footer.html");
}
$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");
include("$host/$query");
} else if (file_exists("$host/pages/" . strtolower($query) . ".html")) {
include_page($host, strtolower($query));
} else {
http_response_code(404);
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 {
http_response_code(404);
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:

epicmc.games/
daltonedwards.me/
.htaccess
index.php

Inside domain directory create two more directories called pages and layout

Page names should be in all lowercase (pages/pagename.html) is accessible at website.com/pagename (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)
Was this article helpful?
Cancel
Thank you!