Hello, Hiawatha newbie here.
PROBLEM: I got a shiny new VPS with an IP address previously used by someone else, and DNS was still directing their defunct domain to my server.
I complained to the VPS provider and they deleted the stale domain entry from their nameservers. This solved most of the problem, except for a few individuals and bots who didn't get the update. So this got me wondering how to stop the problem using Hiawatha.
Hiawatha returns "404 Not Found" for the erroneously-requested pages, but what I really wanted was "410 Gone" to tell bots and humans that the domain isn't on my server. This was actually easy to set up in Hiawatha -- but since I'm a newbie, it took me many hours to figure out. Here's my solution, in case it's useful to any other newbies:
STEP 1: Create "410gone.php" and put it somewhere convenient, like in /var/www/hiawatha/
<?php
header("HTTP/1.1 410 Gone");
?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-US" />
<title>410 Gone</title>
<style type="text/css">
<!--
body {font-size: 100%; color: #000000; background-color: #ffffcc}
h1 {color: #660000; text-align: center}
h2 {color: #660000; text-align: center}
-->
</style>
</head>
<body>
<h1>410 Gone</h1>
<hr />
<h2>
<?php
echo $_SERVER['HTTP_HOST'];
?>
</h2>
<h2>is not on this server</h2>
</body>
</html>
Alter the HTML however you like. The key item here is the PHP "header" function, which puts the "410 Gone" response in the header. "$_SERVER['HTTP_HOST']" is also useful -- it displays the bad domain name for human users.
STEP 2: Add a URL Toolkit to hiawatha.conf
# HTTP header has wrong Host (e.g. from stale DNS):
UrlToolkit {
ToolkitID = 410gone
Do Use /410gone.php
}
STEP 3: Add a Virtual Host to hiawatha.conf
VirtualHost {
# Domain(s) erroneously directed to our IP:
Hostname = example.com
WebsiteRoot = /var/www/hiawatha
# Use FastCGIserver as defined above:
UseFastCGI = PHP7
# Use URL Toolkit(s) as defined above:
UseToolkit = 410gone
}
That's it! Seems to be working for me.
Now all you experienced Hiawatha users can tell me why this is entirely unnecessary or utterly wrong.