Reputation: 174
I am trying to make a custom router. For this I am trying to grab the user requested URL from the application.cfc
. The problem is when a invalid directory or URL is received lucee
directly throwing 404 error
. I just want to get the requested URL and bypass this 404 error. Moreover, after grabbing the URL I want to manually handle the user request.
Upvotes: 0
Views: 83
Reputation: 174
The problem has been solved. Basically, you have to send each request through index.cfm
. So, if you pass an url like localhost:8888/index.cfm/hello/wow
you will not encounter an error and the requested url can be fetched using CGI.REQUEST_URL
(e.g. /hello/wow
).
Moreover, if you want to remove index.cfm
marker you have to enable URL rewrite. Then the url (localhost:8888/hello/wow
) will work without throwing any error.
For URL rewrite refer to these,
Upvotes: 2
Reputation: 754
In your Application.cfc, employ the onMissingTemplate() function which will execute when a template is not found. You can put your custom code handling in there.
More info: https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onmissingtemplate.html
Upvotes: 0