I am working on adding Coldbox to a legacy app, and I’d like to set up a Coldbox route that redirects to an old .cfm file. However, I noticed that the toRedirect() method expects an event and converts all periods into slashes like this:
Now I could handle this at the web server level, by creating some manual redirects. However, I am using Commandbox in development and IIS in production, so I would need to create twice the number of redirect rules. Additionally, I think it would be cool if this could be done in Coldbox as well for more consolidated legacy app migration tracking purposes.
Perhaps the router could have a new method toUri() or there could be a method similar to turning off valuePairTranslation, but instead it wouldn’t treat routes as events like eventTranslation( false ).
Is there another way to handle this in Coldbox, or am I stuck making changes at the web server level for now?
Good call @Andrew_Kretzer. I think that option restricts me to the /views/ folder though. Some of the legacy files in this app are sitting in the web root.
However, your post gave me an idea:
I could create a “shell” view which would simply cfinclude the legacy page, so this could be a viable option! Thank you!
I just discovered another way to do this is to use relocate() inside of the toRedirect() routing method, if you want to perform a redirect instead of a rewrite, like this:
// the URL will change to /foo_bar.cfm
route( "foo/bar" ).toRedirect( function( route, params, event ) {
relocate( uri="/foo_bar.cfm" );
} );