Skip to main content
Inspiring
April 11, 2019
Question

How can I obfuscate by returning a 404 on random hits?

  • April 11, 2019
  • 1 reply
  • 861 views

I have a device portal for IoT that I want to respond with a 404 unless specific criteria are met, to obfuscate for robots, scanning, etc.  How do I force an IIS 404 error from a valid template?

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
April 22, 2019

In ColdFusion, you could achieve this in 2 steps:

1) In the IIS settings of the website, add the path to your custom 404 page. Make sure the first line of code in the 404 page, pnf.cfm, is:

<cfheader statusCode="404" statusText="Not Found">

For more on this, see Duncan's blog.

2) A suggestion for the code in any valid page that you wish to return a status 404

<!--- Define the criteria to be met, encapsulating them in a boolean, isSpecificSetOfCriteriaMet --->

...

<cfif (isSpecificSetOfCriteriaMet) >

   <!--- Put code here that executes when the criteria are met --->

<cfelse>

   <cflocation url="URL_of_pnf.cfm">

</cfif>