Processing files in ColdFusion with an extension other than .cfm

· 1 Comment · in Coldfusion, IIS, More

Want to run ColdFusion code on a page but don’t want the .cfm extension?

Or you have existing pages with an extension of .html and want to add CF code?

You need to update CF and IIS.

These instructions apply to ColdFusion version 9 and IIS 7+.

For this example, we will make updates to support running ColdFusion in files with an .html extension under IIS.

ColdFusion

  1. In a text editor, open web.xml from one of the following locations(back it up first):
    · Multi-server: (jrun_root)\servers\htmlMappings\cfusion.ear\cfusion.war\WEB-INF\web.xml
    · Single server: (cfroot)\wwwroot\WEB-INF\web.xml

    Single server example path:
    C:\ColdFusion9\wwwroot\WEB-INF\web.xml

  2. Find this block of code:

    <servlet-mapping id="coldfusion_mapping_14">
            <servlet-name>CFFileServlet</servlet-name>
            <url-pattern>/CFFileServlet/*</url-pattern>
    </servlet-mapping>
  3. Add this block directly below it (notice the ids):

    <servlet-mapping id="coldfusion_mapping_15">
       		<servlet-name>CfmServlet</servlet-name>
       		<url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping id="coldfusion_mapping_16">
       		<servlet-name>CfmServlet</servlet-name>
       		<url-pattern>*.html/*</url-pattern>
    </servlet-mapping>

    You can add additional code blocks for files with other extensions. Just make sure to update the ids with sequential numbers and add entries into IIS.

  4. Save the file and restart ColdFusion. The easiest way to restart ColdFusion, under Windows:
    Control Panel > Administrative Tools > Services >
    Right-click “ColdFusion 9 Application Server” and select “Restart”

IIS
Select your site in IIS Manager.

  1. Goto “Handler Mappings” and find the entry with *.cfm:
    Double-click it and copy the “Executable” path.
    Close the dialog window.

  2. In right sidebar, click “Add Script Map”.
    Enter the following:
    “Request Path”: *.html
    “Executable”: (paste from clipboard)
    “Name”: Coldfusion html (this can be whatever you want)
    Click OK to save.

  3. Restart your site in IIS.

You should now be able to run ColdFusion code in files with an .html extension!

Great books are available on ColdFusion here.

This entry was posted in Coldfusion, IIS, More and tagged , .
Bookmark the permalink.

One Response to Processing files in ColdFusion with an extension other than .cfm

  1. google.com says:

    Thanks to my father who told me concerning this webpage, this weblog
    is genuinely awesome.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To include code in your comment: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag(or shortcode) and format it when submitted.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">