• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1539
  • Last Modified:

Coldfusion - cfheader statuscode="410" how to implement?

My real estate site site serves up property listings from a database and search engines index the links to these detail pages. When a property is sold or otherwise goes off the market, the property is purged from my database. So the property is gone from my database but the links remain in google serps, bing, etc...and when someone clicks to view the page it generates a soft 404 warning in google webmaster tools. The way I'm currently handling the problem is by using the below code right after the query to grab the proper listing from the database on my detail page .

<cfif result.recordcount IS 0>
<cflocation url="/myerrorpage.cfm">
</cfif>

but this method is does not generate the proper status code, I need a statuscode "410" but im not sure how to implement it.

I tried this:

<cfif result.recordcount IS 0>
 <cfheader statuscode="410" statustext="Gone">
  <cfheader name="Location" value="/myerrorpage.cfm">
  <cfabort>
</cfif>

But the page was still showing: HTTP/1.1 302 Found

here is a sample url:
http://www.fickling.com/104522/304-Imperial-Circle-Warner-Robins-GA.html

Any help is greatly appreciated.
0
Bang-O-Matic
Asked:
Bang-O-Matic
  • 6
  • 5
1 Solution
 
dgrafxCommented:
I believe you can only use one CFHEADER tag on a page and like most things if you use more than one the LAST one will be the one used.

So I believe you can do :
<cfheader statuscode="410" statustext="Gone" />
<cfinclude template="/myerrorpage.cfm">
<CFABORT>
0
 
Bang-O-MaticAuthor Commented:
Hi dgrafx,

that solution works but, I get different results depending on whether I browse the link on my desktop or directly from the web server. If I hit the link from my desktop, i just get  "The page you requested was removed." and nothing else. If I browse the same link from my web server, the errorpage in the include is showing properly.

Any idea why that could be?

Thanks for your help!
0
 
dgrafxCommented:
do you mean that when you are browsing a local version of the website on your development machine then all you get is is "the page you requested was removed"?

are you using any url rewrite?
is the setup the same?
same version of CF?
directory structure the same?
is myerrorpage.cfm the same?
are you using built in CF webserver on desktop or ?
is live webserver IIS or Apache or ?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Bang-O-MaticAuthor Commented:
No I'm browsing the live version, not the local version.
From my PC I just get the "The page you requested was removed." If I log into my VPS server and try to view the same page, I works as it should.
 
It's a windows VPS server running Railo/IIS 7.5
I am rewriting file extensions to .html
and I am rewriting the property url's from the standard
http://www.fickling.com/detail.cfm?MLSNum=118195 
to this:
http://www.fickling.com/118195/1098-Saint-Andrews-Drive-Macon-GA.htm
0
 
dgrafxCommented:
0
 
Bang-O-MaticAuthor Commented:
dgrafx, it's all making sense now!
Thanks again for your help.
0
 
dgrafxCommented:
glad it worked out ...
0
 
Bang-O-MaticAuthor Commented:
well I havent got it working yet but you answered my original question. After looking into my IIS settings there isn't even an error page for status code "410" so I'm thinking it must be a setting in tomcat.
0
 
Bang-O-MaticAuthor Commented:
The problem is solved. Here are the steps:

1. Went into IIS7 and added a custom error page for status code "410" that points to my   off-market.cfm page.

2.On the details page I added:
<cfif result.RecordCount IS 0>
<cfheader statuscode="410" statustext="Gone" />
<CFABORT>
</cfif>

3. On the off-market.cfm page I added <cfheader statuscode="410" statustext="Gone" /> right at the top of the page.

Tested and working.

Thanks again for your assistance.
0
 
dgrafxCommented:
You're welcome

Thanks for posting that so others can hopefully save time with similar issues ...
0
 
srikanthmadishettiCommented:
@dgrafx,

when you say CFHEADER tag can be used only once in a page , Are you saying that you cannot use two cfheader tags  in a single cfm page , If yes then that it is wrong .
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now