ColdFusion 8 has a new attribute in the CFLocation tag called StatusCode. In previous versions, if you wanted to do a 301 redirect, you had to use a combination of two CFHeader tags to accomplish it. As you can see by comparing the old method to the new method below, the good folks at Adobe have saved us 57 keystrokes per redirect by adding this new attribute. As a typical lazy programmer, I sincerely appreciate their efforts.
Old way to do a 301 redirect in ColdFusion:
<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.mynewurl.com">
New way to do a 301 redirect in ColdFusion:
Below is a list of all the HTTP status codes you can use in the CFLocation tags statusCode attribute:
- 300 HTTP_MULTIPLE_CHOICES: The requested address refers to more than one entity.
- 301 HTTP_MOVED_PERMANENTLY: The page is assigned a new URI. The change is permanent.
- 302 HTTP_MOVED_TEMPORARILY: The page is assigned a new URI. The change is temporary.
- 303 HTTP_SEE_OTHER: The client should try another network address.
- 304 HTTP_NOT_MODIFIED: The requested resource has not been modified.
- 305 HTTP_USE_PROXY: The requested resource must be accessed through the proxy given by the Location field.
- 307 HTTP_TEMPORARY_REDIRECT: The requested data temporarily resides at a new location.