Custom Error Pages - what I've done

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 19287
interpreted = N
texte = Following up on some suggestions made by Ken and Britt (thanks as always...) I have been working up a strategy to serve out custom error pages versus the generic Template not found message which is WebCat's default. In order to save new users from the learning curve I thought I'd share what I've done. Comments/criticisms are humbly accepted...SCENARIO #1: You want to serve up a single custom File not found file for all folders or vhosts on your server.SCENARIO #2: You want to allow users to have their own customized File not found error page specifc to their site (or vhost) but in case this file is not present, have WebCat serve up a more generic (but still customized) File not found file.------------------------------- HOW TO: SCENARIO #1 Single customizable error page: This is obviously pretty simple - Simply go to your errormessages.db file and modify the TemplateNotFound error message to something like this:TemplateNotFound [Include /error.html]Where error.html (or error.tmpl or whatever you wish to call the default error page) is your customized File not found file --- be sure to place this file in the root of your web server. That's it, once you have flushed out the old errormessages.db and replaced it with your new version, any missing page requests will recieve this same customizable error.html file.IMPORTANT NOTE: Correctly specifying the path to the location of your included default error.html file is absolutely critical - if you do not specify this properly (or forget to add the file) then you will be literally telling WebCat that in case of a missing file, serve up another file which is also missing etc. etc. -- this creates a nasty WebCat processing loop (bad - very bad...)SCENARIO #2 Folder-specific error pages: The only trick here is that when we recieve a request for a non-existent file we will first look into the current folder to see if an error.html file exists and if so, serve it up, and if it doesn't exist, then we will serve up the server's main defaulterror.html file. So, if a hosting client wants to make sure that only their customized error.html files are servedl, then they will have to place a copy of their error.html file into each subdirectory of their site - if it is missing then the server's default file gets served.WEB SERVER ROOT FOLDER | |-defaulterror.html (server default) | |---WebSite1.com | |- error.html (website1's custom error page) | |-whatever other html is here | |_ subdirectory1 | |- error.html (website1's custom error page or some derivative) | |- whatever other html is here |---WebSite2.com |- error.html (website2's custom error page) |-whatever other html is hereNow add the replace the TemplateNotFound line in your errormessages.db with the following code: [showif [FILEINFO error.html][EXISTS][/FILEINFO]=T][include error.html][/showif] [showif [FILEINFO error.html][EXISTS][/FILEINFO]!T][include /defaulterror.html][/showif]NOTE: Although I left the two [showif] contextsare seperated by a carriage return in the example above (just for visual clarity) the code will not work correctly until you remove all unnecessary spaces and carriage returns.Again, make sure you have flushed out your old errormessages.db and replaced it with your new one as well as properly added all of your error pages.IMPORTANT NOTE (again- applies here as well): Correctly specifying the path to the location of your included default error file is absolutely critical - if you do not specify this properly (or forget to add the file) then you will be literally telling WebCat that in case of a missing file, serve up another file which is also missing etc. etc. -- this creates a nasty WebCat processing loop (bad - very bad...)Of course now that we have WebCat serving up html files instead of a generic message we can go crazy with adding other WebCat tags and commands to our error pages including things like capturing referrer info and automatically logging missing files or generating e-mails to notify webmasters of bad/missing links etc etc.I hope somebody finds this useful. Any comments or suggestions/corrections are appreciated. -Marty --------------------------------- Marty Schmid -Artwerks- e-mail: marty@artwerks.com --------------------------------- Associated Messages, from the most recent to the oldest:

    
  1. Custom Error Pages - what I've done (Marty Schmid 1998)
Following up on some suggestions made by Ken and Britt (thanks as always...) I have been working up a strategy to serve out custom error pages versus the generic Template not found message which is WebCat's default. In order to save new users from the learning curve I thought I'd share what I've done. Comments/criticisms are humbly accepted...SCENARIO #1: You want to serve up a single custom File not found file for all folders or vhosts on your server.SCENARIO #2: You want to allow users to have their own customized File not found error page specifc to their site (or vhost) but in case this file is not present, have WebCat serve up a more generic (but still customized) File not found file.------------------------------- HOW TO: SCENARIO #1 Single customizable error page: This is obviously pretty simple - Simply go to your errormessages.db file and modify the TemplateNotFound error message to something like this:TemplateNotFound [Include /error.html]Where error.html (or error.tmpl or whatever you wish to call the default error page) is your customized File not found file --- be sure to place this file in the root of your web server. That's it, once you have flushed out the old errormessages.db and replaced it with your new version, any missing page requests will recieve this same customizable error.html file.IMPORTANT NOTE: Correctly specifying the path to the location of your included default error.html file is absolutely critical - if you do not specify this properly (or forget to add the file) then you will be literally telling WebCat that in case of a missing file, serve up another file which is also missing etc. etc. -- this creates a nasty WebCat processing loop (bad - very bad...)SCENARIO #2 Folder-specific error pages: The only trick here is that when we recieve a request for a non-existent file we will first look into the current folder to see if an error.html file exists and if so, serve it up, and if it doesn't exist, then we will serve up the server's main defaulterror.html file. So, if a hosting client wants to make sure that only their customized error.html files are servedl, then they will have to place a copy of their error.html file into each subdirectory of their site - if it is missing then the server's default file gets served.WEB SERVER ROOT FOLDER | |-defaulterror.html (server default) | |---WebSite1.com | |- error.html (website1's custom error page) | |-whatever other html is here | |_ subdirectory1 | |- error.html (website1's custom error page or some derivative) | |- whatever other html is here |---WebSite2.com |- error.html (website2's custom error page) |-whatever other html is hereNow add the replace the TemplateNotFound line in your errormessages.db with the following code: [showif [FILEINFO error.html][EXISTS][/FILEINFO]=T][include error.html][/showif] [showif [FILEINFO error.html][EXISTS][/FILEINFO]!T][include /defaulterror.html][/showif]NOTE: Although I left the two [showif] contextsare seperated by a carriage return in the example above (just for visual clarity) the code will not work correctly until you remove all unnecessary spaces and carriage returns.Again, make sure you have flushed out your old errormessages.db and replaced it with your new one as well as properly added all of your error pages.IMPORTANT NOTE (again- applies here as well): Correctly specifying the path to the location of your included default error file is absolutely critical - if you do not specify this properly (or forget to add the file) then you will be literally telling WebCat that in case of a missing file, serve up another file which is also missing etc. etc. -- this creates a nasty WebCat processing loop (bad - very bad...)Of course now that we have WebCat serving up html files instead of a generic message we can go crazy with adding other WebCat tags and commands to our error pages including things like capturing referrer info and automatically logging missing files or generating e-mails to notify webmasters of bad/missing links etc etc.I hope somebody finds this useful. Any comments or suggestions/corrections are appreciated. -Marty --------------------------------- Marty Schmid -Artwerks- e-mail: marty@artwerks.com --------------------------------- Marty Schmid

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Tab Charactor (1997) Three new problems ... (1997) mac os HOG? (2001) Banners (1997) Checking Out! (1999) no template caching (1997) taxTotal, grandTotal (1997) cc auth with [purchase] (1998) WebCat2b13MacPlugIn - [include] doesn't allow creator (1997) Comments in db? (1997) SiteGuard Admin Feature ? (1997) Ok here is a question? (1997) [CreateDate] tag? (1998) WebMerchant when CC network is down (1998) enhanced ErrorMessages.db (2002) Email within tmpl ? (1997) WebCat2b13 Mac plugin - [sendmail] and checkboxes (1997) Problem with empty form-variables in [search] (1998) Bug or syntax error on my part? (1997) Date Formats (1997)