DMCA takedown? Use HTTP error code 451!

A few hours ago, I received a delightful (or as delightful as they can be) copyright infringement takedown notice — what’s known in the trade as a “17 USC 512 (c)(3)(A)” or “DMCA” notice of infringement. Rather than remove the content permanently as if it never existed (and thus risking having people email me to ask where it went), I decided to do something a little different.

A little over a year ago, Tim Bray (@timbray) proposed that HTTP error code 451 be allocated for use in occasions like this. (I’ve linked to the latest draft at the time of writing, draft-tbray-http-legally-restricted-status-03, dated July 10, 2013).

The first problem is that Apache doesn’t recognise this error code, so you can’t use it in a Redirect directive. Thankfully there’s a workaround – create a PHP script which serves up the 451 error, then use mod_rewrite to redirect relevant requests to the script. Let’s say we want to block an entire directory…

First we create a .htaccess file in that directory, containing these two lines:

RewriteEngine On
RewriteRule .* .451.php

This enables mod_rewrite and redirects any requests to pages within this directory to the HTTP 451 handler script. Note that there’s a leading period on the script filename – this is intentional (on UNIX systems, a hidden file is denoted by a leading period in its filename).

Now we create the PHP script:

<?php header("HTTP/1.1 451 Unavailable for Legal Reasons"); ?>
<html>
<head>
<title>HTTP/1.1 451 Unavailable For Legal Reasons</title>
</head>
<body>
<h1>HTTP/1.1 451 Unavailable For Legal Reasons</h1>
<p>This request may not be serviced as a result of the issuance of a 17 USC 512 (c)(3)(A) (DMCA) infringement notice by Bilbo Baggins, Editor In Chief, Shire Weekly, relating to an article entitled "My Journey to Mordor," authored by one Frodo Baggins.</p>
<p>The aforementioned DMCA notice is on file at <a href="http://www.chillingeffects.org/12345">The Chilling Effects Clearinghouse</a>.</p>
</body>
</html>

Obviously the text of the error message is only an example and you should edit it to suit your circumstances.