How can I use ColdFusion to affect the status code returned on a page request?

Posted on 2009-04-24
Medium Priority
Last Modified: 2012-05-06
I know this is a little wierd, but I am using my 404 error page to run a content management system. For example, if you go to http://www.datacollaborative.com/AboutUs, there is no page called "AboutUs/index.cfm" or anything like it. So the server goes to the 404 page, which looks at the URL and decides what text to display.

The problem is that I am afraid that while the page looks fine, the header is sending back a 404 which will confuse search engines. For example, cgi.query_string="404;http://www.datacollaborative.com/aboutus".

I would like to specifically set the http status in my code, so I can send back a 200 if I want to indicate that the page is found (even though there is no real page with that filename), and a 404 if it really is not found. However, I cannot find any response header that will set the status code.

Thanks in advance for any help.

Also, if you are the kind of person who can help with this, you may also be able to help on a related question that I am posting simultaneously, where I am trying to send back header data that will include the (faked) resource location.
Question by:DataCollab
LVL 52

Accepted Solution

_agx_ earned 2000 total points
ID: 24225675
Have you tried using cfheader to set the status code returned?

<cfheader statuscode="xxx" statustext="Status text here" />


Author Closing Comment

ID: 31574198
That did it!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question