HOWTO: Return "410 Gone" for an entire domain

Bill Statler
5 December 2017, 05:02
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/

header("HTTP/1.1 410 Gone");
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en-US" lang="en-US">
<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}
<h1>410 Gone</h1>
<hr />
<h2>is not on this server</h2>

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 =
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.
Hugo Leisink
5 December 2017, 14:21
Since it works, it's definitely not 'utterly wrong'. And you figured it out by yourself. So, well done!
Vladas Palubinskas
5 December 2017, 16:42
I would put StartFile = 410gone.php directive to VirtualHost{} instead of inclusion UrlToolkit{}. But I am newbie, too.
Bill Statler
5 December 2017, 21:52
Thanks, Hugo, and thank you for making Hiawatha available. I'm liking it a lot.

Vladas, if I understand things right, "StartFile = 410gone.php" would work if a client was trying to access directly, but would not work if they tried to get (which is what most of my confused visitors were doing).
Hugo Leisink
6 December 2017, 09:02
Correct. The StartFile setting only affects requests for the root, not for specific files.
This topic has been closed.