05 July 2006

Misc: Redirecting Web Visitors

After moving all my stuff to my new web site, I thought it'd be simple to redirect all the visitors from the old site to the new one. After some false starts, I found that the easiest method is the following:

  1. Create a moved.html file with <META HTTP-EQUIV="refresh" content="5; URL=http://kamhungsoh.com">.
  2. Copy moved.html to index.html.
  3. Create a .htaccess file with this rule: ErrorDocument 404 http://members.optusnet.com.au/khsoh/moved.html.
  4. Delete all files and folders on the old server and upload the new files.
The META directive in the HTML files tell the browser to load a new URL after 5 seconds. The index.html handles the case when a visitor only enters the URL without any file name. If the visitor enters the URL for a file name, then the ErrorDocument rule is activated and the moved.html is displayed.