Redirect a moved URL

       384 words, 2 minutes

When a Web site is modified, there are some pages that disappear or move. Either because you change the content manager or because you rearrange your Web pages, some of them may become unavailable.

Nobody likes 404 pages, neither the users, nor Google bot. Here’s how to tell both of them when an URL has permanently moved or was just deleted.

You can manage error and redirect pages from your content manager. I use WordPress and Joomla for various purpose and both have plugins to manage those error from the administration panel. In this article, I’ll focus on using the <strong>.htaccess</strong> file as it would be CRM independent.

Gone with the wind, Error 401 Gone

I used to store NetBSD binary packages on my early Web site. There are still some links to this repository from here to there. For example, when you try to browse to , you’ll get a

HTTP/1.1 404 Not Found
Status: 404 Not Found
Connection: close  

This sub-directory won’t exist anymore. So let’s tell the Word:

# vi .htaccess  
Redirect gone /pack/NetBSD-4.0_BETA2/i386/All/ 

Now what we get is

HTTP/1.1 410 Gone

There is even a human message saying:


The requested resource /pack/NetBSD-4.0_BETA2/i386/All/ is no longer available
on this server and there is no forwarding address. Please remove all references
to this resource. 

Now, let’s go a bit further and let’s advertise for the death of the whole /pack/ section:

RedirectMatch gone ^/pack/.*

Please hold the line, we’re trying to connect you, Error 301 Moved Permanently

My Web site was first built “with the hand” using Vim and SSH. Then I used Dokuwiki. And finally went to WordPress. Funny to see the history here .

Anyway, for example, the “P2V from Se7en to VirtualBox” page is not available from “/en/docs/virtualization/p2v_7vbox” anymore. But the page does still exists. Here’s how to tell the world:

**RedirectPermanent** /en/docs/virtualization/p2v_7vbox /20100727/p2v-from-se7en-to-virtualbox/ 

The user’s navigator will be redirected to the new location. Behind the hoods, here’s what’s said:

HTTP/1.1 301 Moved Permanently

Should the Web browser not implement the redirection, it will show the following text:

The document has moved [here][2]. 

If you need to redirect a whole section, you can use:

RedirectMatch** permanent ^/en/docs/virtualization/(.*$) /tag/virtualization/

Now, parse your Web log and fill-in your <strong>.htaccess</strong>

That’s All Folks!