CFLib.org – Common Function Library Project

cf301Redirect(urlString)

Last updated December 6, 2008

Version: 0 | Requires: ColdFusion MX | Library: UtilityLib

 
Rated 1 time(s). Average Rating: 4.0

Description:
Takes a url and 301 redirects to user to that url. Please note - ColdFusion 8 adds the statusCode attribute to be cflocation. This UDF should only be used in ColdFusion 6 and 7.

Return Values:
Returns nothing.

Example:

view plain print about
<cfset cf301Redirect( 'http://google.com' ) />

Parameters:

Name Description Required
urlString URL to push the user to. Yes

Full UDF Source:

view plain print about
<!---
 Takes a url and 301 redirects to user to that url.
 
 @param urlString      URL to push the user to. (Required)
 @return Returns nothing. 
 @author Erik Vold (erikvvold@gmail.com) 
 @version 0, December 6, 2008 
--->

<cffunction name="cf301Redirect" access="public" returntype="void" output="false">
  <cfargument name="urlString" type="string" required="yes" />
  
  <!--- 301 redirect the user to the provided url --->
  <cfheader statuscode="301" statustext="Moved permanently" />
  <cfheader name="Location" value="#arguments.urlString#" />
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
29 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson