HTTP Error 410: Gone

It has been a while since I changed the backend of my site from NewsPro to Movable Type.

A side effect of this change was that all pages changed URL, which I considered a minor problem since most people enter the site through the home page (which did not change).

Normally I try to keep URL’s the same, but the old system used horrible filenames like 1025286960,58049,.html and stored all files in a single directory.

Like I said, most visitors enter the site through the front page, but there are some people looking for specific information with search engines. Until today these visitors were presented a ‘404 Page not found’ error page of my provider directly followed by the homepage of my provider. In other words, these visitors end up at a completely useless page, and won’t ever visit my site anymore!!!!

Something had to change. First, I wanted to change the error message from 404 (Not Found) to 410 (Gone), since the latter message is more precise. All visitors looking for never-existing files will still get the old 404 message. I read about this code a while ago on dive into mark, and I kept it in mind for using it on m own site.

Secondly, I want to show them another page, which at least links to my site. For the moment I chose to present them the search page, so at least they can search my site for the information they are looking for.

I am planning to create a separate error page explaining what has happened in more detail, but until now I will just show the search page.

So how did I set this all up?

The Apache server has the ability to specify configuration options in a file called .htaccess. The settings in this file are valid for the current and all underlying directories, and thus can be overruled by another file.

I created this file in the root directory of my site and added the following information:

ErrorDocument 410 /cgi-bin/mt/mt-search.cgi RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} ^/cgi-bin/newspro RewriteRule cgi-bin/newspro/(.*) - [G,L]

In ‘normal’ language, these lines say the following:

The first line says that the page at /cgi-bin/mt/mt-search.cgi (which is my search page) has to be shown in case a request has status ‘410: Gone’.

The second and third lines activate and configure a module for the Apache webserver calles mod_rewrite, which allows me to process the next two lines.

The fourth line defines the condition to me used for the rewrite. It says: if the requested URL starts with /cgi-bin/newspro.

The last line specifies what has to happen if the condition above is met: rewrite cgi-bin/newspro/. with nothing (-). Besides the rewrite (which does nothing) two options have been specified: G and L. The first changes the status to Gone (410), and the L tells that this is the last rule to process.

In short: if the URL contains /cgi-bin/newspro, the status will be changed to Gone, and when error 410 (Gone) occurs, the search page will be shown.

Jeroen Sangers @jeroensangers

An IndieWeb Webring 🕸💍