If someone requests a non existent .cfm page, I’d like to send them to a custom 404 page.
Lucee Admin > Settings > Error > Missing Template Error (404)
I’ve set a custom 404.cfm page there, but I’m not sure what variable to use to display the url the user requested.
I want to show the user ‘mypage.com/doesntexist.cfm’. What variable to do I use to get that info? ‘cgi.server_name’ is only giving me the host name.
I found this code that seems to work. Is there a better way?
<cfoutput>http<cfif cgi.https is "on">s</cfif>://#cgi.server_name &
you can omit the http or https and just use a protocol relative url like “//#cgi.server_name##cgi.script_name#”
or even just #cgi.script_name#
also remember that cgi variables are user provided so they should be escaped like form or url variables