(Update: I converted this question to a community wiki, as the answer seems more subjective than I thought. It will be a few answers depending on needs.)
If I have a folder that only includes application.cfc and index.cfm, what is a quick, reliable method for handling dynamically generated URLs? that is, URLs that do not have a corresponding physical .cfm file.
This url example generates 404, but it should look for the page in db and return it via index.cfm:
http:
Should I use onMissingTemplate () in application.cfc to handle the missing file? Since this method does not handle onRequestStart (), onRequest (), and onRequestEnd (), I wonder if it should be avoided.
Alternatively, I can configure the ISAPIRewrite rule, since I use IIS (or mod_rewrite on Apache)
RewriteCond %{SCRIPT_NAME} ^(?!/index.cfm)(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\/(.*)\.(cfm|html)(\??)(.*)$ /index.cfm?page=$1.$2&$4 [I,L]
Are these methods suitable, or am I missing the best way to achieve this? It seems that Coldfusion should have such a function built into application.cfc. Maybe I just missed it.
source
share