Introduction:
As you may have noticed on pages like Google, you will see that they have a program called ‘search?’ and many people have wondered how you can run a Coldfusion page without any extension to mimic that.

The reasons can be for Security, because they don’t want people to know they are running CF, or just for clean looking links.

I personally am not an advocate of Extensionless Coldfusion but the demand has been such that it should be addressed.

What you need:
You need access to the Apache httpd.conf file OR the IIS6 MMC Snap in
You need access to the Coldfusion default-web.xml
and you must be able to restart the ColdFusion and Apache service.

The Technique:
There are two parts to setting this up, one is the configuration of your web server, and the second is the configuration of Coldfusions web.xml.

In Coldfusion 5 you would just pass a file to Coldfusion and Coldfusion would try and process it, so you could tell IIS to pass *.myFiles to Coldfusion and Coldfusion would happily try and render it.

In Coldfusion MX the principle is a little bit the same, but you have to set the default-web.xml to listen for the files extension.

So what we are going to do is tell Apache/IIS to pass the Jrun mod our file, and then have Jrun process it and pass back to Apache/IIS to be served up as rendered html

The catch:
The catch quite simply is that with this technique you cannot just upload any extensionless file and expect Coldfusion to run it, you have to explicitly declare each file and its name in Apache/IIS AND the default-web.xml, so if you have 10 pages you wish to make extensionless, you have to add that name to both sources and restart the services.

Another Interesting caveat is that if you have
http://www.mysite.com/myFile.cfm/id/360 , this will become
http://www.mysite.com/myFile/id/360
In Apache on Windows and Linux you can get away with this however on IIS you can’t as it treats MyFile as a directory as opposed to a file, where as apache will check, because on both windows AND Linux you cannot have a file and a directory of the same name.

Both IIS and Apache can handle http://www.mysite.com/myFile?id=360

Our test page:
For our test we will be using a file called ‘service’ which will be a Coldfusion text file

Modifying Apaches httpd.conf
Open your httpd.conf file in your favorite text editor and find the section of code that looks like this

LoadModule jrun_module "C:/CFusionMX/runtime/lib/wsconfig/1/mod_jrun20.so"

<IfModule mod_jrun20.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ssl false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/CFusionMX/runtime/lib/wsconfig/1/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51010
    #JRunConfig Errorurl <optionally redirect to this URL on errors>
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc
</IfModule>

On the AddHandler line, add the name of your file, so in our case it will be ‘service’
It should resemble this

AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc service

Save this file and restart your Apache installation

Modifying IIS6
Open up the IIS MMC snap in from the Administrative Tools folder and browse to your website.
Right click the website and click properties.
Click the Home Directory tab and then click the Configuration button under Application Settings
You should see a box at the bottom called “Wildcard Application Maps” and in there is listed is

C:\CFusionMX\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll

If you don’t see that, then just add it. Press OK to take you back to the properties screen and press the HTTP Headers tab, and then click the Mime Types button, then click New.
In the Extension box, put ‘.*’ and then in the MIME Type field put in

application/octet-stream

Press OK and then OK again, Just for good measure, restart IIS (though you shouldn’t have to).

Modifying Coldfusions default-web.xml file
Open <CF_SERVER_ROOT>\runtime\servers\default\SERVER-INF\default-web.xml in your favorite text editor and under <description> Settings</description> add this

<servlet-mapping>
<servlet-name>CfmServlet</servlet-name>
<url-pattern>service</url-pattern>
</servlet-mapping>
Save the file and restart Coldfusion

The Service file
Create a file called Service and copy and paste this

<html>
    <head><title>
Extentionless CF Test</title></head>
    <body>
    <p><font face=
"Tahoma" size="6">Extenionless Coldfusion Test</font></p>
    <hr color=
"#FF9933">
    <p>
&nbsp;</p>
    <CFIF IsDefined('form.action')>
        <cfoutput>
Hello #form.yourname#!</cfoutput>
    <cfelse>

        <form name="myForm" action="service" method="POST">
            What is your name : <input type="text" name="yourname">
            <input type="hidden" name="action" value="go">
            <input type=
"submit" name="submit" value="submit">
        </form>

    </CFIF>
    </body>
</html>

Save the ‘service’ file and upload to your coldfusion server and then go to
http://www.yoursite.com/service

You should now see a fully rendered CF page used without extensions!

What this has been tested on:
Windows Server 2003 Standard with ColdFusion MX 6.1 and IIS6
Windows XP Professional with Coldfusion MX 6.1 and Apache 2.05
Redhat Linux 9 with Coldfusion MX 6.1 and Apache 1.3

About This Tutorial
Author: Alex Allen-Turl
Skill Level: Intermediate 
 
 
 
Platforms Tested: CFMX
Total Views: 164,168
Submission Date: October 27, 2005
Last Update Date: June 05, 2009
All Tutorials By This Autor: 1
Discuss This Tutorial
  • I have successfully made my server handle url like "http://www.yoursite.com/service", but when i use a url like "http://www.yoursite.com/service/a/b", i got a 404 error thrown by jrun server. How can i pass variables to this page with this formation of url?

Advertisement

Sponsored By...
Dripping Springs, Texas - Deep Tissue Massages and Swedish Massages!