Utility Function: PermanentRedirect()

I really can't take any credit for this one. The idea and the core code come from Pete Freitag's blog post "What CFLOCATION Does". Its probably not even original to wrap it in a function, but here it is any way.


<cffunction name="PermanentRedirect" output="false" returntype="void">
    <cfargument name="url" type="string" required="false" />
    
    <cfheader statuscode="301" statustext="Moved Permanently" />
    <cfheader name="Location" value="#arguments.url#" />
    
    <cfabort />
    
    <cfreturn />
</cffunction>

 

Comments

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.