Custom 404 Page - Apache/Tomcat/Lucee

235 views
Skip to first unread message

s...@retrose.org

unread,
Jul 26, 2016, 4:06:53 AM7/26/16
to Lucee
I have been trying to figure out how to create a custom 404 page, and am having no luck.

In my application.cfc, I have:

<cffunction name=“onMissingTemplate”
  <cflocation url=“/404.cfm”> 
</cffunction>

Any clues?

andreas

unread,
Jul 26, 2016, 4:09:54 AM7/26/16
to lu...@googlegroups.com
a cflocation to a 404-Error-Page is not a good idea: the cflocation returns a 302-Status-Code. In other words you would return a 302-Code, instead a 404.

I would make use of cfheader, and depending on your configurations your front-end-webserver could serve a custom-error page.

--
Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/aeee9b81-8380-421a-8d85-a1727307255e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

s...@retrose.org

unread,
Jul 26, 2016, 5:04:27 AM7/26/16
to Lucee
So assuming I am running multiple sites, so need a custom 404 for each site, how would you go about  doing this?

Luke

unread,
Jul 27, 2016, 4:01:13 AM7/27/16
to Lucee
following on from what andy said, you can add a status code to a cflocation;

<cflocation url=“/404.cfm” statuscode="404"> 

Andy Rueger

unread,
Jul 28, 2016, 5:50:45 AM7/28/16
to Lucee
as far as I know statuscode 404 in cflocation won't work, that should throw an error. cflocation is there to change location by 30x headers. This can cause a 302/301 redirect to an error page that only shows a 404 content, but no 404-Status-Code. That's not good for SEO.

Better is to throw a cfheader with 404 status code followed by any content. That can be created in many ways: include-files, functions, custom-tags, but depends on setup of the front-end webserver. We use IIS, that is why I really can't recommend a way to set it up in apache.

We had problems with 404 error codes being interpreted as 200 OK Success in the past: these page were indexed by search engines. That's why it is important to always check the status code with a browsers developers tool (i.g. firebug) when delivering status codes. Sorry for not giving a better help :/
Reply all
Reply to author
Forward
0 new messages