Description

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

Category

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.

See also

History

ColdFusion 11: The addToken attribute is modified. If Secure Profile is enabled, addToken's default value will be "false".

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

Default value is false (when the secure profile enabled).

The clientManagement attribute must be enabled (see cfapplication).

  • yes: appends client variable information to URL.
  • no

 

New in ColdFusion 11: If Secure Profile is enabled, addToken's default value will be false.

 

statusCode

Optional

302

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.

Note:

When using cfabort, cflocation, or cfcontent tags, the OnAbort method is invoked instead on OnRequestEnd.

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"> --->

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy