This is the preferred method of redirecting to other web pages, and additional information can be found at http://www.w3.org/QA/Tips/reback.
As the P-A Department's main web server uses the Apache HTTP server program, here is how to do it on that system (for other systems' servers, see the references in the www.w3.org web page noted above).
Create a file in the directory in question called " .htaccess " and put into it the line
Redirect /path-of-file-to-be-redirected URL-of-page-to-go-to
For example, if you are a professor teaching the (fictitious - for the sake of the example only) PHY386 course during Spring Semester 2007, but you want to keep your web pages in a subdirectory of your own user area instead of in the courses area provided, you can go to the appropriate courses area on the server, /web/documents/courses/2007spring/PHY386 and put
Redirect /courses/2007spring/PHY386/index.html http://www.pa.msu.edu/people/username/subdir/index.htm
(all on one line, in case the above example is wrapped by your browser) into a file called .htaccess which has world-read permissions (that's the default).
The "path" argument is relative to the "web root", so in the above example, "/web/documents" is left off. The "page to go to" URL is a full URL, even if the web page is on the same server. More than one Redirect command can be put into the .htaccess file, and you can redirect all files in a directory to their equivalents in a "to go to" directory by leaving the filenames off.
A case where more than one Redirect command may be necessary is when a web page may be accessed via more than one URL. In the above "PHY 386" example, in fact, the instructor will have to add a second line, the same as the first, except for lower-case "phy386" instead of "PHY386" in the "path" argument, because the web page may be accessed with the "phy386" URL, too. During Spring Semester 2007, the page could also be accessed with URLs with "current" in place of "2007spring" and with "2007spring" left out entirely, bringing the number of Redirect commands up to six for that one page. Fortunately, a URL which leaves off the "index.html" filename defaults to assuming it, or else three more Redirect commands would be needed to handle those cases. (The folks at w3.org still consider this as preferable to a single "refresh" meta command in the file itself, which would be read and acted upon regardless of how the file was accessed, as described below.)
If there is already a .htaccess file in the subdirectory in question, see the Apache HTTP server documentation to see where in it the Redirect command should be placed. If you are the person running the Apache web server program on a system, you can also put instances of the Redirect command into the server configuration file instead of, or in addition to. htaccess files in specific subdirectories (again, see the Apache HTTP server documentation for the details).
"refresh" meta command
Note that this method is
deprecated by the official HTML standards organization in favor of the server-based redirect method described above.
You can set up a web page to inform any browser which happens to load it that there is another web page it should go to instead, after an optional delay.
This is accomplished using a "refresh" meta command in the header section of your HTML file, along with the title and any "keywords" or other meta commands.
The syntax for the "refresh" meta command is
<meta http-equiv="refresh" content=" N ; URL= other-web-address ">
where N is the approximate number of seconds that you want the current web page to be displayed before the browser automatically goes to the other web address. If N = 0. then the browser should go immediately to the other web address.
In case someone's browser doesn't handle these automatic redirects (most browsers do handle them, but some allow them to be turned off, as a way of discouraging "web spam", which often uses this type of "refresh" redirect), you may want to provide a second route to the intended destination by way of a standard link (see the example, below).
Select Example above or here to see how the example works in practice.
Notes on scripting languages