ColdFusion offers the ability to enable a variety of custom extensions within your application so that CFML pages don’t have to be processed using the standard .cfc or .cfm files. This feature is especially helpful for users who are wanting to hide their application’s identity for security purposes. In this article we will cover the steps required for allowing HTM/HTML pages to be processed as CFML pages on a ColdFusion Server 1.
NOTE: Please note that this change will effect every site on your server.
Steps to process HTM/HTML pages as CFML:
Locate your “web.xml” file within ColdFusion - First you will need to locate your “web.xml” file located within your ColdFusion application folder. This file can be located in the following location:
<cf install path>/<instance name>/cfusion/wwwroot/WEB-INF/
The default location for this would be:
Windows: C:\ColdFusion2016\cfusion\wwwroot\WEB-INF\
Linux: /opt/coldfusion2016/cfusion/wwwroot/WEB-INF/
We’ll continue utilizing ColdFusion 2016 on Windows for enabling this feature. The correct path to the “web.xml” file has been listed below.
C:\ColdFusion2016\cfusion\wwwroot\WEB-INF\web.xml
Edit your web.xml file - Now that you’ve located your web.xml file you will need to make some modifications. Open your web.xml file with an editor of your choice and search for a ColdFusion servlet mapping named “coldfusion_mapping_1”. Once you’ve located this mapping continue scrolling through all of the ColdFusion servlet mappings until you get to the last one. After scrolling down to the last number increment you should see the following:
<servlet-mapping id="coldfusion_mapping_16">
You will then want to add the following servlet mappings under the closing tag within your web.xml file.
<servlet-mapping id="coldfusion_mapping_16">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping id="coldfusion_mapping_17">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.html/*</url-pattern>
</servlet-mapping>
<servlet-mapping id="coldfusion_mapping_18">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping id="coldfusion_mapping_19">
<servlet-name>CfmServlet</servlet-name>
<url-pattern>*.htm/*</url-pattern>
</servlet-mapping>
Save this file and exit.
3. Create your new HTM/HTML as CFML mappings in IIS - Now that you’ve added your new servlet mappings you will need to create new mappings within IIS. To do this you will need to open IIS on your server and complete the following:
Click your server’s Server ID directly wihtin IIS. (This is located under the ‘Start Page’ of IIS. https://img.hostek.net/i/7b8fbb6a27dd83f7a529 4)
Click the ‘Handler Mappings’ icon.
Select and ‘Edit’ the .cfm extension listed within your handler mappings and copy the executable “Value” being specified. In my case this value is “C:\ColdFusion2016\config\wsconfig\1\isapi_redirect.dll”.
After copying the executable value click cancel and then click ‘Add Script Map’.
Paste the executable value that you previously copied from your *.cfm extension and type *.htm in the ‘Request Path’ and click OK.
Repeat the above steps to add a handler mapping from *.hmtml requests.
4. Configure your ColdFusion connector to process HTM/HTML extensions as CFML - Lastly, you will need to adjust your ColdFusion connector’s “uriworkermap.properties” file to process HTM/HTML extensions as CFML. On standard installations of ColdFusion this file is located below:
<cf install path>/<instance name>/config/wsconfig/1/uriworkermap.properties
Once you’ve located this file open it in your favorite text editor and copy the following lines at the bottom of the file, then save and close the file:
/*.html = cfusion
/*.htm = cfusion
After completing the above steps you will need to restart the ColdFusion service and IIS to apply these changes. Once your services have been restarted ColdFusion will began processing CFML within HTM/HTML files.
Congratulations! You’ve successfully configured HTM/HTML extensions to be processed as CFML pages. If you have any issues with this process, then our world class team of ColdFusion experts can help. Please view our article on submitting a ticket (link) if necessary.