UMD Web Site

Page Content   Main Links   Page Links   Utility Links   Search   Footer Links

ColdFusion Development Project

cf_redirect

Redirects a browser to another location using either an HTTP status code in the header or a cflocation tag. This tag can also send an email notification with a user-defined message and subject.

<cf_redirect
type="301|302|location"
location="url"
email="email address(es), multiples separated by commas"
emailsubject="subject line"
addtoken="yes|no">
[Optional email message]
[</cf_redirect>]

Attribute Req/Opt Default Description
type req. "301" The type of redirect used.
location req. none The location to send the browser to. This should be an absolute URL where possible.
email opt. none The email address to send the notification response to. If left blank, no email will be sent. Separate multiple email addresses with commas.
emailsubject opt. "Redirect Page Accessed" The subject of the notification email.
addtoken opt. "no" Gives the value of the "addtoken" attribute. Used only if "type" is set to "location". See cflocation documentation for more information.

HTTP status codes are sent to web clients (which include browsers) that tell the client what to expect. "200" means the resource was found and the information is being sent; "404" means the resource was not found. The 300 level codes all involve a redirect to a new location.

The type values you can use are:

  • 301: The resource has moved permanently and can no longer be found at the requested location. The requested location should not be used in the future by user agents.
  • 302: The resource has moved, but user agents can continue to use the requested location to access the resource.
  • location: executes a cflocation tag, which sends a '302' status code message.

There are other codes in the 300 level, but they either do not work across all browsers or are irrelevant for web page redirects.

Search engines will note the 301 and 302 status codes and update their search listings according to their schedules and settings. The 'location' type will also deliver a '302' status code and should be considered the same thing. However, cf_redirect should not be used to bring extra traffic to the new location; search engines will catch on and demote the destination site in search rankings accordingly. Use cf_redirect to aid in site maintenance and organization only. Ideally, the pages using cf_redirect should be removed after a set period of time, after the search engines have had a chance to crawl them (for '301') or the need for the temporary redirect has passed (for '302').

The 'location' type is included for comprehensiveness. For all useful purposes, it is the same as '302'. The "addToken" attribute corresponds to the "addtoken" attribute of the cflocation tag.

cf_redirect is unnecessary when the site or page in question will be used regularly but infrequently (for example, the New Student Orientation site, which is used primarily during the spring and summer). Site organization and planning is still important; cf_redirect will not help sloppy organization, in fact it could make it worse by helping create a tangled mess of redirects. Use cf_redirect sparingly.

Using multiple cf_redirects in a page is not recommended, and may result in errors. However, you can use conditional logic to decide among several redirect options. The redirect will override any further processing of the web page and will immediately reload the web browser. This means any additional content on the page will not be delivered to the user. If you wish to deliver any important content to the user before sending them to the new location, it is better to deliver a standard web page with a prominent link to the new location and not use cf_redirect.

The email function can be used to send an email whenever the redirected resource is accessed. This is particularly useful when the time comes to remove the redirect, as any stray links can be found and tidied up before they go bad. You may specify multiple emails in the "email" attribute, and specify a custom subject line and a custom message between the opening and closing </cf_redirect> tags. This tag uses the isEmail() function to determine if the email address(es) you give is valid.

Case Examples:

Case: A site has been reorganized. Resources that were spread across several pages are now contained in one page, or information that was put in one location has  been organized into a new folder hierarchy.

Solution: Use <cf_redirect type="301" location="new_url_here"> in each page that needs to be redirected to the new location. After some time, for example 3 months, the old pages should be removed completely.

Case: The campus is holding a night of fireworks. A page has been set up with information about the events and festivities, but the URL is long and/or complicated or is hosted on an external website. The publicity materials require a short and simple URL. After the fireworks, the page will not be needed.

Solution: Set up a one-page site. Use <cf_redirect type="302" location="new_url_here"> or <cf_redirect type="location" location="new_url_here"> inside that site's welcome.cfm. All traffic will be forwarded to the new location, but the old location will still be used by search engines. When the event has passed, either remove the one-page site completely or change the redirect to a type 301 and remove it a few weeks later.

Case: A new initiative requires a new site. Or, a new student club has been started and needs a new site.

Solution: Set up the new site in an established location according to demand and policy. Do not use cf_redirect. The site's organization and deployment should be planned so that a redirect is not necessary.

Case: A department is updating their course listings on their web site. They are replacing one file with another (ex: 'spring06.cfm' with 'fall06.cfm'), and want to redirect everyone from the old location to the new location.

Solution: Keep the old file name if it is generic enough (courses.cfm vs. fallcourses.cfm), or rename the file to something more generic yet topic specific (i.e., courses.cfm). Use this file for all updates now and in the future. Do not use cf_redirect; change links where appropriate throughout the site to point to the new page.

Contact Info:

Email: webdevelopment@umassd.edu - Web Design & Development

Main Links

Page Links

Utility Links

Search

 
Text Only Options

Top of page


Text Only Options

Open the original version of this page.

Usablenet Assistive is a UsableNet product. Usablenet Assistive Main Page.