cflocation

Description

Stops execution of the current page and opens a ColdFusion page or HTML file.

Syntax

<cflocation 
    url = "URL" 
    addToken = "yes|no" 
    statusCode = "300|301|302|303|304|305|307">
Note: You can specify this tag’s attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag’s attribute names as structure keys.

History

ColdFusion 8: Added the statusCode attribute.

Attributes

Attribute

Req/Opt

Default

Description

url

Required

URL of HTML file or CFML page to open.

addToken

Optional

The clientManagement attribute must be enabled (see cfapplication).

  • yes: appends client variable information to URL.

  • no

statusCode

Optional

The HTTP status code, as follows:

  • 300 HTTP_MULTIPLE_CHOICES: The requested address refers to more than one entity.

  • 301 HTTP_MOVED_PERMANENTLY: The page is assigned a new URI. The change is permanent.

  • 302 HTTP_MOVED_TEMPORARILY: The page is assigned a new URI. The change is temporary.

  • 303 HTTP_SEE_OTHER: The client should try another network address.

  • 304 HTTP_NOT_MODIFIED: The requested resource has not been modified.

  • 305 HTTP_USE_PROXY: The requested resource must be accessed through the proxy given by the Location field.

  • 307 HTTP_TEMPORARY_REDIRECT: The requested data temporarily resides at a new location.

The status codes from 304 to 307 do not redirect you to the page specified in a URL, unless you also follow the guidelines specified in the most recent HTTP RFC.

Usage

You might write a standard message or response in a file, and call it from several applications. Use this tag to redirect the user’s browser to the standard file.

This tag has no effect if you use it after the cfflush tag on a page.

Example

<h3>cflocation Example</h3> 
<p>This tag redirects the browser to a web resource; normally, you would use this tag to go to a CF page or an HTML file on the same server. The addToken attribute lets you send client information to the target page.</p> 
<p>If you remove the comments, this code redirects you to CFDOCS home page:</p> 
 
<!--- <cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "no"> --->