Trailing slash after index.cfm file functionality

I am sure this is something simple I am overlooking but… I am running Lucee on Windows 2016 server and IIS and have found something, well odd.

If I make a request {domain}/foo I properly get a 404 error. However if I request {domain}/index.cfm/foo I get a 200 response and the text of the Index page.

For Non CFML sites requesting {domain}/index.html/foo generates a 404 error.

I looked in the Tomcat web.xml file and removed (commented out) the url-patterens that I thought caused this but it is still happening. Is this normal behaviour? Why? And how do I change it? Thank you.

Tomcat web.xml;

<servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfm</url-pattern>
        <url-pattern>*.cfml</url-pattern>
        <url-pattern>*.cfc</url-pattern>
	<!-- Basic SES Mappings ** commented out **
	<url-pattern>/index.cfc/*</url-pattern>
	<url-pattern>/index.cfm/*</url-pattern>
	<url-pattern>/index.cfml/*</url-pattern>
	--> 
</servlet-mapping>

If you are wanting the iis 404 to kick in, you need to stop iis from sending the request to cf in the first place. By the time the servlet mappings are in place, it’s too late. Even hitting /totallyfake.cfm will cause iis to pass it off to Lucee. The Adobe connectors used to have an option to check for the file’s existence. I assume you’re using Boncode, but I’m not sure if it has that setting. Even if it did, it would break the Lucee admin among other things.

If this is the case, then of what use are the servlet URL parameters? I know that once iis hands it off to Tomcat it is up to Tomcat and Lucee to generate an error, however that is not happening with a request for a valid cfm page that is followed by a slash – example: index.cfm/anythinghere. Instead it processes the page but in the context of a separate directory breaking all the relative references such as for CSS and .JS files.

The behaviour I am trying to get for index.cfm/foo is the same as I should get for totallyfake.cfm. How would I do that?

If this is the case, then of what use are the servlet URL parameters?

Sorry, what “servlet URL parameters” are you asking about?

I know that once iis hands it off to Tomcat it is up to Tomcat and Lucee to generate an error, however that is not happening with a request for a valid cfm page that is followed by a slash

Why would that throw an error? It’s perfectly valid.

example: index.cfm/anythinghere. Instead it processes the page

That’s correct, and I assume it’s because your web.xml has a servlet mapping that matches that pattern and forwards that request on to the CFML Servlet.

but in the context of a separate directory breaking all the relative references such as for CSS and .JS files.

This has nothing to do with Lucee and is simply how your browser interprets relative paths. If using SES-style URLs, the onus is on you to use a base href in your HTML to define where relative paths actually start to the browser. Or use full paths for your static assets like /js/jquery.js

The behaviour I am trying to get for index.cfm/foo is the same as I should get for totallyfake.cfm. How would I do that?

I thought I explained that in my previous post. You still haven’t told us how you are proxying requests which makes it a little hard to continue helping you, but assuming still that you are using boncode, I would start with this setting inside your handler mappings:
image

Alternatively, if you want Tomcat to get the request and use Tomcat’s 404 handler, then adjust your web.xml servlet mappings. Check that what you say you commented out above is in the correct web.xml, that you commented out all instances, and that you restarted Tomcat.

If you want IIS to send a 404 for any CF SEO URL like that then try adding a new handler to your web.config:

<system.webServer>
 <handlers>
  <remove name="Handle-CF-SEO-URLs-As-404" /><!-- for safety -->
  <add name="Handle-CF-SEO-URLs-As-404" path="*.cfm/*" verb="*" modules="StaticFileModule" resourceType="File" />
  ...
 </handlers>
</system.webServer>

This obviously needs to precede your .cfm/.cfc handlers.

I apologize for not being clear.

the onus is on you to use a base href in your HTML to define where relative paths actually start

My initial internal response from this was " pashaw…of course we set the base href in all the html code" but no longer being a teenager I instead checked to see what was set for that application and sure enough that tag was blank. :woozy_face: I should have known better and must be slowing down in my old age.

But that still leaves me trying to fully understand the functionality of the Tomcat server in regards to this particular function. This installation is a windows install on 2016, IIS and using the Lucee installer that uses the bonocode connecto and installs Tomcat in C\Lucee\tomcat folder. The web.xml file for tomcat is located in the C:\lucee\tomcat\conf folder and is the only web.xml in the C:\Lucee path tree.

Removing or commenting out the “index.cfc/", "index,cfm/” and “index.cfml/*” from that section (posted above) of the web.xml file, the only section in that file referencing those patterns, restarting Tomcat or rebooting the machine did not change the behaviour for a request for “index.cfm/foo” as I expected. I expected Tomcat to throw an error of some kind.

So I guess my question is why did it not, and what should I have expected?

By the way, thank you.