Skip to main content
Participant
August 3, 2007
Question

How to page request without .cfm extension

  • August 3, 2007
  • 5 replies
  • 977 views
I have a site where I want Fred to enter the url http://www.mydomain.com/fred in his browser and Joe to enter url http://www.mydomain.com/joe. I want to parse the name after the last slash, then send the user (with cflocation) to home.cfm, which will be customized for this user.

I was hoping that my "missing template handler" page would be called (since there are no files called fred.cfm or joe.cfm), and then I could get the name from cgi.SCRIPT_NAME, but it looks like the web server rejects this request first. I know I could just add .cfm to the end of the url (e.g. http://www.mydomain.com/fred.cfm), which WOULD send me to my missing template page, but for aesthetic reasons, I don't want to use the extension. (I want the user to be able to put the url on his business card, and the .cfm tacked on the end doesn't look good.)

Anyone know of a solution? Thanks.
This topic has been closed for replies.

5 replies

August 5, 2007
Duplicate
August 5, 2007
No need to get the servers involved. On test.cfm, place a the following single line of code:
<CFDUMP VAR=#CGI#>
Run http://domain.test.cfm/joe and see what you get for CGI.PathInfo.
Inspiring
August 3, 2007
As well as reconfiguring your web server 404 handler to a CFM template
as previously suggested. You can use a form like this -
http:\\myDomain.com\aPage.cfm\Joe. This may or may not appeal to you,
but it is a common method to make "Search friendly urls" that could
fairly easily be adopted for your functionality.
Inspiring
August 3, 2007
You will need to configure your web server (IIS, Apache, or other) to handle this. If the web server does not recognize the request as being associated with ColdFusion ( *.cfm ) the missing template handler will never be invoked.

You might try associating the web server's file not found 404 error response with a custom web page or URL containing your redirection logic.

I would be interested in hearing how you resolve this challenge. Please post your solution to the forum.
August 3, 2007
The CGI.PathInfo variable will contain "/joe" when you go to http://www.mydomain.com/joe