New StatusCode Attribute in CFLOCATION

August 01, 2007

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

Related Entries

14 people found this page useful, what do you think?


great info, thanks Pete!
Recently cflocation on an SQl action page was not protecting me from refresh after redirect. Changed to your solution above and bingo - thanks!
Cool, thanks for the info. I love finding tips like this :)
Teentop links directory, link exchange, add url, add link
thanks for the cool info, I wasn't aware of this

Recent Entries


did you hack my cf?