This page is an archive of my old blog. Please visit for my current blog.
This site is no longer being maintained and commenting is disabled.

Keeping Old Links Functional

When a site is completely redesigned in such a way that the URL structure will change, it is important to keep your old links functional. Recently, a large organization (which shall remain nameless) retooled their website. This included changes to several often used URL's. This organization also had many smaller sites that referenced these URL's. By utilizing the Redirect directive in Apache - you can easily map the old URL's to the new locations. If this organization had followed these steps, the developers could have avoided several angry emails.

Apache has supported the Redirect directive since Apache 1.2. It utilizes mod_alias to actually redirect the requests. As long as you have imported the module (see Code Example 1), you can use a simple Redirect statement in your httpd.conf file (see Code Example 2).

  1. ...
  2. LoadModule alias_module modules/
  3. ...

Code Example 1 - Importing mod_alias

Mod_alias will be imported by default on most new Apache installations. To actually perform the redirect, you simply need to utilize the proper syntax: Redirect [status] URL-path URL. The status field accepts a few different values (from documentation):

  • permanent - Returns a permanent redirect status (301) indicating that the resource has moved permanently.
  • temp - Returns a temporary redirect status (302). This is the default.
  • seeother - Returns a "See Other" status (303) indicating that the resource has been replaced.
  • gone - Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the URL argument should be omitted.

  1. Redirect permanent /oldurl.html

Code Example 2 - Importing mod_alias

By utilizing this functionality, you can map every old URL to the new location. You also could go a step further and have Apache log resources that are still referencing the old URL's. This way you could determine if any old links still exist before you remove the redirects.

Note: If you choose not to implement these Redirect statements, you at the very least need to have a functional 404 Page that can assist visitors in getting to where they were going.

Comments are closed.