Skip to content Accesskey=4Skip to sub-navigation Accesskey=NView our Accessibility Options MIT Information Services and Technology Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

Web Publishing Reference
 

Web Reference home

MIT Guidelines

Creating Web Pages

Using MIT Web Space

 

File Transfer
Permissions
Lockers
Server Options
Page redirects

web.mit.edu Resources

MIT/IS&T Resources

Training

Search the Web Reference:

 

Page Redirects

When you rename a page or move a page or site from one directory location to another, this results in a change in URL for that page or site. Without a redirect page, users following links to the old URL will get a 404 (Page not found) error. Since you may have users who have bookmarked specific pages on your site or there may be other web sites linking to your pages, its a good idea to set up a redirect so that visitors will automatically route to the new location, as invisibly as you desire. You can either do this using the meta-refresh approach or with Apache's mod_alias module.

Meta-refresh

In the META-HTTP-EQUIV tag, the content attribute indicates how many seconds (in the example below, 5 seconds) before the user is whisked off to the new location specified in the URL attribute. We recommend using 3-5 seconds on all redirects so the users are made aware that the page has moved and have time to read the short message displayed. Zero second redirects are not recommended if you want your users to update their bookmarks.

You may copy this code to create a new page at the old location, editing appropriately:

<!doctype html public"-//w3c//dtd html 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Refresh" content="5; 
    url=http://www.newlocation.com/page.html">
<title>Please note the change of address!</title>
</head>

<body bgcolor="#ffffff">

<h2>We have moved! Please update your bookmarks! If you are
not automatically redirected to the new address in 5 seconds,
please go to <a href="http://www.newlocation.com/page.html">
	http://www.newlocation.com/page.html</a></h2>

</body>
</html>
        

mod_alias

The Apache module mod_alias allows you to provide intelligent, seemless, and nearly instantaneous redirection for pages that have moved. The way in which it redirects your end-users may be of less concern to you than the way in which it redirects search engines. By providing the appropriate HTTP response codes, using mod_alias vs. the meta-refresh approach will improve your search engine listings (internally and externally).

By customizing your .htaccess.mit file (in this case usually one at the root of your web site, in the same directory as your home pages) you can indicate whether certain content has moved temporarily, permanently or has been removed altogether.

Redirecting a single page

Redirect permanent /one http://example.com/two
Redirect 301 /one http://example.com/two

Redirect temp /one http://example.com/two
Redirect 302 /one http://example.com/two

Redirect gone /one http://example.com/two
Redirect 410 /one http://example.com/two

Redirect seeother /one http://example.com/two
Redirect 303 /one http://example.com/two

Redirecting many pages

You can redirect many pages using pattern matching RedirectMatch 301 /ist/web/(.*)$ http://web.mit.edu/wcs/$1
When used on Athena, the line above will permanently redirect requests for any content in the web subdirectory of the ist locker to corresponding URLs in the wcs locker. (e.g. http://web.mit.edu/ist/web/reference/index.html will be permanently redirected to http://web.mit.edu/wcs/reference/index.html)

For more information: see the Apache Group's documentation on mod_alias

   
MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.

Mit Counter