[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-08-11
12
Medium Priority
?
1,470 Views
Last Modified: 2012-08-16
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
Comment
Question by:Bang-O-Matic
  • 6
  • 5
12 Comments
 
LVL 25

Accepted Solution

by:
dgrafx earned 2000 total points
ID: 38285314
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
 

Author Comment

by:Bang-O-Matic
ID: 38287748
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
 
LVL 25

Expert Comment

by:dgrafx
ID: 38287795
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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:Bang-O-Matic
ID: 38287910
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
 
LVL 25

Expert Comment

by:dgrafx
ID: 38287979
0
 

Author Closing Comment

by:Bang-O-Matic
ID: 38288241
dgrafx, it's all making sense now!
Thanks again for your help.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 38288255
glad it worked out ...
0
 

Author Comment

by:Bang-O-Matic
ID: 38288920
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
 

Author Comment

by:Bang-O-Matic
ID: 38289512
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
 
LVL 25

Expert Comment

by:dgrafx
ID: 38289864
You're welcome

Thanks for posting that so others can hopefully save time with similar issues ...
0
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 38299758
@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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

872 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