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
/blah
into
/index.cfm/blah
you need a rule that rewrites
/subDir/blah
into
/subDir/index.cfm/blah
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
<url-pattern>/subDir/index.cfml/*</url-pattern>
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
yoursite.com/subDir/index.cfm/blah
which does not require the rewrite. Once that is verified, modify and test your new rewrite rule against
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.
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.
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();
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.