Copy link to clipboard
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?
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 --->