Monday, February 13, 2006

coldfusion redirect

If you ever need to do a 301 redirect all you need is these 2 lines of Coldfusion code

<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.kfc.com">

Note that the cfheader tag can be used to write the Coldfusion headers but needs to be the first thing on the page.

As a result its normally best to put this in the Application.cfm. file

What is Application.cfm? It’s a file which is processed by coldusion before every request for a Coldfusion page – its typically used for logging, or preventing access to pages – as well as session management. It must start with a capital A. It is not executed when requests are made for non Coldfusion pages so often you may decide to change a html site to a .cfm just so that you can make use of this functionality.</cfheader></cfheader>

No comments: