pf » What CFLOCATION Does
What CFLOCATION Does

It is often stated that CFLOCATION does a client side redirect. This means that it sends back some HTTP headers telling your browser to request a different location. This is done with a 302 (Moved Temporarily) HTTP status code, and the Location header. Here's what the HTTP response might look like:
HTTP/1.1 302 Moved Temporarily Content-Type: text/html; charset=UTF-8 location: /anotherPage.cfm Connection: close Date: Mon, 16 May 2005 18:27:21 GMT Server: Apache
CFLOCATION should only be used for temporary redirects.
For permanent redirects use the 301 HTTP status code, which stands for Moved Permanently. You can do this with the CFHEADER tag:
<cfheader statuscode="301" statustext="Moved Permanently"> <cfheader name="Location" value="http://www.petefreitag.com/"> <cfabort>
It is important that you use the correct status text Moved Permanently as defined by the HTTP RFC.
Related Entries
- New StatusCode Attribute in CFLOCATION - August 1, 2007
- CFLOCATION tags revised Gustavus Web Services
can you define "Moved Temporarily" Vs "Moved Permanently" ?
- especially in the context of "just using the cflocation tag" when you've finished processing a form and want to redirect the user (and deliberatly don't want to - or can't - use
getPagecontext().forward()
or are you saying that MACR have got it wrong and cflocation should be changed?
thanx barry.b
I think the main benefits to not using a CFLOCATION to do a redirect are for SEO reasons... So for instance if you have a domain called 8ball.com, and you also own eightball.com - using a CFLOCATION to do redirects from eightball.com to 8ball.com is a bad idea from a SEO standpoint.
Ray the cases your point out I think are indeed temporary redirects, I'd use cflocation for those.
So permanent redirects are things like if you delete an ID and it no longer exists you want to do a perm redirect to the main articles listing, instead of a cflocation.
No I haven't had any problems with this in firefox. Make sure your using the proper status text "Moved Permanently"
However, If you are doing something like chcing domain names in your application.{cfm|cfc} then you want to be sure that you use a 301 redirect, indication that the move is permanent, and search engine will index it just fine. They don't like temp redirects (302) why should they index something marked as temporary?
But I have to ask why redirect to home.cfm to begin with?
Thanks
For example: .../mydomain.com/mypage.cfm?param1=value#location
In this case I have an anchor on mypage.cfm called ?location? and I want to point the browser at it. I also have a parameter called param1 with a value of ?value?.
It seems that the cflocation tag dose not parse this url properly and, at lease in my case, I was actually getting the location tacked onto the back end of cftoken. Needless to say it wreaked havoc on my session.
The three lines provided above work out for me with the following stipulation. The url had to be page name followed by the parameter followed by the location, as shown above. It would not work if the location followed the page name and preceded the parameter. Go figure.
Thanks for the cold fusion insight,
Jeff
It fails (however) to tell me which words. And as it is a rather long text i can't just 500x try and error it :-(
cflocation seems to bind threads, causing timeouts to occur. Is there an inherent performance problem with cflocation?
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
- 10 Most Useful Image Functions in ColdFusion 8
- Speaking at NYC CFUG This Week
- Adobe AIR Tutorial for HTML / JavaScript Developers
- INFORMATION_SCHEMA Support in MySQL, PostgreSQL
RSS
add to del.icio.us
Pete Freitag is a software engineer, and web developer located in









