Problem with Router.cfc

Sorry for the poor question…

I have a fully functional Coldbox installation (v. Coldbox-6.4.0) for some API Rest.
I’m using
Now, I would to activate the url rewriting but I cannot make my Coldbox reads the Router.cfc configuration.

Tuckey UrlRewrite works perfectly, and i add to my urlrewrite.xml the required rules find here:
https://coldbox.ortusbooks.com/the-basics/routing/requirements/rewrite-rules

The documentation says that by default the Router.cfc file is searched in the “config/Router.cfc” folder.

This is the shema folders of my application:
/config/Coldbox.cfc
/config/Router.cfc
/api/Application.cfc (which starts Coldbox)

I tried putting Router.cfc in:
/api/config/Router.cfc
without success.

Any idea?

Many many thanks

Assuming you created your app using ColdBox REST HMVC template (coldbox-templates · GitHub), the Router.cfc should be in wwwroot/modules_app/api/modules_app/v1/config/Router.cfc

I hope that helps.

Thanks for your reply @Ancient_Programmer :smile:

Assuming you created your app using ColdBox
REST HMVC template

Actually not.
I made a custom installation.
My coldbox is in /external/coldbox

I have done this mapping:
this.mappings["/coldbox"] = ExpandPath("/external/coldbox/");

I have configured the controller directory as such in /config/Coldbox.cfc
handlersExternalLocation: "com.smartvillage.api.controller"

My controllers extend the AbsController which itself extends:
coldbox.system.RestHandler

I have put Router.cfc in the directory: /config/Router.cfc

Application.cfc is in /api/Application.cfc (this starts Coldbox)

Everything works perfectly!

But I cannot make Coldbox read Router.cfc.

I cannot find a way to point this file in the configuration.

Any idea?

You put Router.cfc in /config. That should work. Have you reinitialized the framework?

http://yourdev/?fwreinit=1

http://yourdev/?fwreinit=1

yes, i put:

url.fwreinit = 1;

on my OnRequestStart() :sweat_smile:

What’s your Web server? I’m curious.

i’m using CommandBox :slight_smile:

You mentioned that your ColdBox 6.4 could not read Router.cfc. Honestly, I’ve never had that issue before. Perhaps, it’s worth to look at server.json. Below is what I usually have on my local set up using CommandBox.

{
"name":"myapi",
"app":{
    "cfengine":"lucee@5"
},
"web":{
    "host":"localhost",
    "directoryBrowsing":false,
    "rewrites":{
        "enable":"true"
    },
    "aliases":{
        "/media":"/Users/local/sites/api/media"
    }
}

}

Ok, i solve the problem :sweat_smile:
I was wrong in configuring my urlrewriting.xml :laughing:

:grin: Incident like that could happen to anyone.

1 Like