Pete Freitag Pete Freitag

New StatusCode Attribute in CFLOCATION


When ColdFusion 7 came out I did a series of blog entries on small often overlooked new features. Well ColdFusion 8 is now out, and I thought it would be a good idea to do the same.

One handy new feature in ColdFusion 8 is the statusCode attribute in the CFLOCATION tag. I wrote a blog entry a while back called What CFLOCATION Does? - it explains that CFLOCATION does an HTTP 302 Moved Temporarily

redirect. Often times for SEO reasons you will want to do an HTTP 301 Moved Permanently redirect. When a search crawler sees a 301 redirect it forward all pagerank, backlinks, google juice, whatever you want to call it - on to the new url.

In the past you would have had to do something like this to do a 301 redirect with ColdFusion:

<cfheader statuscode="301" statustext="Moved Permanently">
<cfheader name="Location" value="">

Now, in ColdFusion 8 you can simply use the CFLOCATION tag with the statusCode attribute:

<cflocation url="" statuscode="301" addtoken="false">

According to the documentation the statusCode attribute accepts the following status code values: 300, 301, 302, 303, 304, 305, 307

Like this? Follow me ↯

New StatusCode Attribute in CFLOCATION was first published on August 01, 2007.

If you like reading about cflocation, cfml, redirect, or http then you might also like:

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.

The weekly newsletter for the CFML Community


great info, thanks Pete!
by BigTallGeoff on 08/03/2007 at 6:41:53 AM UTC
thanks for the cool info, I wasn't aware of this
by Steve on 08/10/2009 at 11:00:28 AM UTC