Help create a default handler for a directory

I have a sub folder named app/blah.
I have a number of handlers in that folder but I need a default handler for when someone just navigates to http://someserver/blah

Right now it wants to show the directory, which clearly is not what I want.
It looks like the systems checks to see if a folder exist and if it does it stops processing and just displays the folder.

I would like to have something like:

route( “/blah”, “blah.login.index” ).end();

Or just don’t match folders only, so that the default fires.

@powertoaster There are two things necessary for fully-rewritten SES URLs to work in a subdirectory

  • Framework rewrites in place that account for the sub folder
  • A double wildcard *.cfm/* servlet mapping

The default ColdBox rewrites are ONLY to work for an app in the web root, so instead of having a rule that rewrites




you need a rule that rewrites




That will take care of the first bullet, but the second bullet depends on whether you’re using Lucee or ACF and how they are configured. Adobe CF and CommandBox will always support SES URLs in sub folders because they are magic. A default Lucee installation is constrained by Tomcat, and will likely require you to add a servlet mapping of


for any subdirectories where you want SES URLs to work.

In order to simplify this, tackle the second bullet first and get this URL working

which does not require the rewrite. Once that is verified, modify and test your new rewrite rule against

I am using Lucee with the commandbox docker image.

I am assuming that I need to add that redirect manually as part of my image build, assuming that this is out of scope for the default config stuff.

I have two web.xml files in the image.

If you’re using CommandBox, then that automatically takes care of bullet #2 so forget about your web.xml. So the next question is how and where are you performing your URL rewrites for this app?

  • A web server like Nginx sitting in front of docker?
  • CommandBox’s Tuckey-based rewrites?
  • CommandBox’s Server Rule rewrites?

If you simply have web.rewrites.enable set to true in your server.json, then that would be Tuckey.

Yes it is Tuckey.

We are in development testing at this point so will probably have a different fronting solution later.

Here are the default rewrites

You’ll need to make a copy of this file with the modified rewrites and point your server.json to use it. You should just need to change these 2 lines

		<to type="passthrough">/subDir/index.cfm/$1</to>

Perfect I will let you know how it works.

1 Like

I still don’t understand why the router did not kick in. Because it should have. The only thing that might have prevented that would be tuckey @bdw429s where it detected it as a directory and tried to do directory browsing on it. Because in reality, I would have expected route( "/blah", "handler.action" ) to work.

I really tried to get this working this way but kept running into problems.
In the end I reset everything back to a clean app.

I then ran:
coldbox create handler blah/hello index

Edited the Router.cfc and added this line:
route( "/blah", "blah/hello.index" ).end();


Now it does exactly what I expected in the beginning.
If I navigate to localhost:8080/blah it goes to the blah/hello.index that I expected.

Not sure why it did not work before.

Minor update: I went back through all of my code and the comments that I posted originally.
The flaw was in the original router code:
I used route( “/blah”, “blah.login.index” ).end(); instead of route( “/blah”, “blah/login.index” ).end();

Note the / instead of the .

One thing to note. The route() method has the pattern and the target arguments. If you pass the target argument, that will terminate the route for you. Calling .end() on it, virtually does nothing for you. So you can clean it up if you need to.

1 Like