- Use SES format
like http://www.web.com/index.cfm/action/overview/userID/15.
The cgi.scriptname then contains a variable named path_info that contains the string (in this case) /action/overview/userID/15. - use mod_rewrite for Apache
This allows you full flexibility over handling certain URL's like:
http://www.web.com/username
Well, use Railo for it. Unlike in other engines, the Application.cfc is called even for non existing .cfm files. So for instance, if you call a non existing page like: www.mycommunity.com/members/Overview/Tanja.cfm the application.cfc which is located somewhere inside or above the folder members gets involved. Let's assume normally you would call a fusebox action and pass the username in order to get the page for the user with the username Tanja. This URL might look like follows: www.mycommunity.com/members/index.cfm?fusebox.action=Overview&userID=34
Here's a way of how to implement that in the Application.cfc:
<cfcomponent hint="Main entry point">
<cffunction name="onRequest" output="Yes" returntype="void">
<cfargument name="requestURL" required="Yes">
<cfset var aParams = ListToArray(arguments.requestURL, "/")>
<cfset var iParamLen = ArrayLen(aParams)>
<cfset var sUserName = ListFirst(aParams[iParamLen])>
<cfset var sAction = aParams[iParamLen -1]>
<cfquery name="getUserInfo" datasource="someDatasource">
SELECT UserID
FROM Users
WHERE userName like '#sUserName#%'
</cfquery>
<cfif getUserInfo.recordCount neq 0>
<cfset url.userID = getUSerInfo.userID>
<cfset url["fusebox.action"] = sAction>
<cfinclude template="index.cfm">
<cfelse>
<cfinclude template="userNotExisting.cfm">
</cfif>
</cffunction>
</cfcomponent>
3 responses so far ↓
1 Jason // Feb 28, 2008 at 7:47 PM
Or does it have to end in .cfm?
2 Gert Franz // Feb 28, 2008 at 8:49 PM
you could configure your webserver to act like that. The only thing what you have to do is to configure the webserver to invoke the appserver defined for Railo for every directory lookup. And then let the appserver like resin handle any filetype with the Railo servlet.
Gert
3 Justin Carter // Feb 29, 2008 at 6:21 AM
For those on IIS, URL rewriting is still possible with this free ISAPI filter, I use it with all my FarCry sites:
http://www.codeplex.com/IIRF/
Leave a Comment