Quackit Logo

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE hosting.

$1.99 Domain Names

With every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99.

ColdFusion Redirect

Print Version

If you're familiar with HTML, you may have learned how to perform a URL redirection using the meta tag. If not, you can learn how to do that in 30 seconds on this HTML redirect page.

In ColdFusion, redirects can be done via one of two methods. The method you use will depend on the reason for the redirect.

Temporary Redirects (cflocation)

This is the most commonly used of the two - you will probably find yourself using the cflocation tag often.

A temporary redirect is typically used when you need to redirect the user to another page based on some logical rule in your program. For example, straight after they submit a form, the browser might redirect to another page.

ColdFusion includes the cflocation tag for performing temporary redirects. This actually sends HTTP headers to the user's browser indicating a 302 status code, which means "Moved Temporarily".

<cflocation url="/new_location.cfm">

Permanent Redirects

A permanent redirect should be used when a page no longer exists.

Permanent redirects use the 301 HTTP status code, which means, "Moved Permanently". In ColdFusion, a permanent redirect can be achieved using the cfheader tag.

<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="http://www.quackit.com/coldfusion/tutorial">
<cfabort>

In case you're thinking, "but users can't see the status code anyway", that's only partially true. The 301 status code can be very useful for search engines. They will actually take notice of your 301 status code and index the correct file.

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
               
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!