Search | Directories | Reference Tools
UW Home > UWIN > Computing and Networking > Web > Web Publishing 

Redirecting Visitors to a New Location

Summary

If you have moved your Web site, this article can help you redirect visitors from your old Web site location to your new one. The instructions below help you to set up a message on your old Web site that instructs visitors to update their links and bookmarks before it automatically redirects them to the new location.

Note: you must remove all old files and directories from your web directory in order for this method of automatic redirection to work correctly.

Instructions

The following instructions show how to set up redirection for a Web site on the depts.washington.edu. With minor substitutions, the same method works for Web sites on other UW Web servers.

  1. Make sure your new Web site is up and running and ready for public browsing. Visitors will be redirected from your old Web site to your new Web site as soon as you have completed these steps.

  2. Log in to your Homer, Dante, or Shell.MyUW.net account.

  3. Press the O key for Other, then press the W key to drop into the Web development environment.

  4. At the prompt, enter the following command to change into to your Web directory:

    cd public_html
  5. Edit the home page of your old Web site. To do so using the Pico editor, enter:

    pico index.html
  6. At the top of the home page, add two "meta" tags:

    <meta http-equiv="refresh" content="5;url=http://www.newsite.washington.edu">
    <meta name="robot" content="noindex,follow">

    Replace http://www.newsite.washington.edu with your new Web site's location. Replace 5 with the number of seconds that a browser should wait before automatically redirecting visitors to the new location.

    The second meta tag, <meta name="robot" content="noindex,follow">, tells search engine “crawlers” or “robots” to stop indexing your old Web site but still to follow the link to the new location and index the new Web site. This tag is optional and does not affect redirection. Still, it is worth using “for good form” as more and more search engines look for this tag.

  7. Modify the rest of the home page, adding a message and link to inform visitors about your site's new location. When complete, the entire HTML source might look like this:

    <html>
    <head>
        <title>This Web site has moved</title>
        <meta http-equiv="refresh" content="5;url=http://www.newsite.washington.edu">
        <meta name="robot" content="noindex,follow">
    </head>
    <body>
    Our Web site has moved. Please update your links and bookmarks.
    This page will redirect you to <a href="http://www.newsite.washington.edu">our
    new location</a> in 5 seconds.</a> 
    </body>
    </html>
    
  8. Save the modified home page (in Pico use ^X).

  9. At the prompt, enter the following command to create a .htaccess file in the current working directory:

    pico .htaccess
  10. Add the following line to this file:

    ErrorDocument 404 http://depts.washington.edu/oldsite/

    Replace http://depts.washington.edu/oldsite/ with the location of your old Web site's home page. This location corresponds with the home page you just modified.

  11. Save the .htaccess file (in Pico use ^X).

  12. Remove all the old files and subdirectories from your Web directory, leaving behind just two files: your modified home page (index.html) and the .htaccess file you just created.

  13. You're done! Anyone who tries to access a Web page for your old Web site will be presented with the home page you just modified to help visitors find your new Web site. (But how does it work? It is a variation of a custom error message. By removing all the old Web pages, except for the home page, and by adding the .htaccess file, all requests for files that are not found now go thru your modified home page, and from there, on to your new Web site.)