Browser-Based Redirect

If you have moved your website, this article can help you redirect visitors from your old website location to your new one. The instructions below help you to set up a message on your old website 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 website on the depts.washington.edu. With minor substitutions, the same method works for websites on other UW Web servers.

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

  2. Log into your web development server using a terminal emulator. If you're not sure how to do this, click here for instructions.

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

    cd public_html

  4. Edit the home page of your old website. To do so using the Pico editor, enter:

    pico index.html

  5. 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 website'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 website but still to follow the link to the new location and index the new website. 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.

  6. 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 website has moved</title>
        <meta http-equiv="refresh" content="5;url=http://www.newsite.washington.edu">
        <meta name="robot" content="noindex,follow">
    </head>
    <body>
    Our website 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>
    
  7. Save and close the file using Pico. (Click for instructions on how to use pico).

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

    pico .htaccess

  9. 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 website's home page. This location corresponds with the home page you just modified.

  10. Save and close the file using Pico. (Click for instructions on how to use pico).

  11. 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.

  12. You're done! Anyone who tries to access a Web page for your old website will be presented with the home page you just modified to help visitors find your new website. (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 website.)

     

Last modified: June 21, 2013