ColdFusion and Dynamic SES (Search Engine Safe) URL's : Part 2

Revisiting SES's

If you read my last post on Search Engine Safe (SES) URL's, you may have noticed that it was pretty basic. But like everything I post, it's kind of a work in progress.

Anyways, I've been working on a project and I had to revisit using SES's and I discovered another trick. Basically what I had before, using a URL parameter, should still be valid. If you don't remember, it looked something like this:

http://www.whatever.com/products.cfm?id=2369/accessories/gloves/Fuzzy+Pink+Mittens/

I've been tracking a few of my websites using Google Analytics and so far this method seems to be working fine. The one thing that bothers me though, is that I still see sites using another method, and I couldn't figure out how they were doing it. Basically the URL looks something like this:

http://www.whatever.com/index.cfm/accessories/gloves/Fuzzy+Pink+Mittens/

Notice how they are not using a URL parameter? Yeah, that boggled me nogg'n. So I did some digging and some experimenting and here's what I came up with. Basically you can pull the part that's after the index.cfm by checking the CGI.PATH_INFO parameter.

<cfoutput>#CGI.PATH_INFO#</cfoutput>// Result --> /accessories/gloves/Fuzzy+Pink+Mittens/

Now that I have this information I can use it for whatever my needs might be. QUERY's, CFC's, etc. I've made a little function that will return the results into an array.

<cffunction name="getCurrentPath" output="No" returntype="Array">
   <cfif CGI.PATH_INFO contains "&">
      <cfset url_str = ListGetAt(CGI.PATH_INFO,1,"&")>
   <cfelse>
      <cfset url_str = CGI.PATH_INFO>
   </cfif>
   <cfset url_str = REReplaceNoCase(url_str,"^\/|\/$","","ALL")>
   <cfset url_array = ListToArray(url_str,"/")>
   <cfloop index="i" from="1" to="#ArrayLen(url_array)#">
      <cfset url_array[i] = URLEncodedFormat(url_array[i])>
   </cfloop>
   <cfreturn url_array />
</cffunction>

This would return these results with the same example above:

[0] accessories[1] gloves[2] Fuzzy+Pink+Mittens

The only other thing I would like to figure out is how they do the same thing without actually using the index.cfm in the URL. Is suspect that this is done with ColdFusion 8, since you are able to use the Application.cfc which allows you to use onRequestStart method. Basically this is called before the page load, but I haven't played with this much yet. I'll be sure to let you know!

1 responses to "ColdFusion and Dynamic SES (Search Engine Safe) URL's : Part 2"

popmYT
To me the benefit for us CFML developers is in the greater adoption (and the attendant increase in numbers of developers using the language) that Railo and OpenBD can bring to CFML as a language and community. For Adobe, I think the profit lies in Bolt (or whatever it will be called). Assuming a greater number of CF users (sites, developers, etc.), the need for a standard IDE increases (no knock on CFEclipse...I love and use it daily). I, personally, think this is where Adobe sees the dollars (see the opening of Flex as a server versus the incredible sales of Flex Builder since version 2 as a model).
Doug
Doug responds:
@popmYT - Wrong blog post?

Have something to say? Leave a comment!

You don't have to be registered to leave a comment. Unregistered user's comments will be approved before going live.




You are currently posting as an unregistered user.
This means that your comment will be reviewed prior to going live. If you are a registered user, please . New user? No problem, register for an account, it's FREE! Benefits include, posting instantly, screen name protection, collaboration recognition, subscribe to article updates, and so much more!