Skip to main content
Participant
May 1, 2009
Question

URL manipulation

  • May 1, 2009
  • 1 reply
  • 986 views

Can anyone explain how to manipulate the URL so it uses a meaningfull title fromt the database.

Or can anyone tell me the name of the piece of script that i would use so i can search for more information on the database

This is what we are after

Instead of -

http://www.fishtec.co.uk/ProductDetailInfoWithOptions.cfm?ID=F-BTOOTHXT&ShopRef=23&Prime=Yes&shopListRec=38135

We are hoping it would say somthing more usefull like

http://www.fishtec.co.uk/-Bluetooth-XT-Fly-Rod

Any info much appreciated

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 1, 2009

    You can setup a routine in your CF application, which is typically placed in Application.cfc or Application.cfm (whichever you use) to parse quasi-SES-style URLs. However, at this level your URL would still need to have the CFM file in it (http://mydomain.com/index.cfm/one/two/three).

    To use URLs that do not use a CFM file, you must handle this before CF gets the request (i.e., at the server level). The two ways to do this are (a) at the server level with a Rewrite Rule or (b) by using an established CF framework (Fusebox, Model-Glue, Mach-II, ColdBox, CFWheels, etc.), which often uses server RewriteRules to accomplish such tasks.

    While many of the popular frameworks for CF allow the use of SES-style URLs out of the box (well, just about out of the box!), you would need to rebuild your app to use the framework and I know that often isn't realistic.

    What server are you using?

    If it's Apache, you would only need to enable the Rewrite Module (mod_rewrite in httpd.conf) and add your Rewrite Rules accordingly.

    If you're on IIS, I've read about Rewrite Rule filters for IIS but have no experience with them (ISAPIRewrite seems to be the one that gets mentioned the most).

    If you're using a Java server (Tomcat, JBoss, etc.), you also need to get a third-party filter, the most common of which is called UrlRewriteFilter.

    Ray Camden has a nice blog post about handling SES-style URLs directly from CF (it's from 2005 but still has lots of good and relevant bits in it):

    http://www.coldfusionjedi.com/index.cfm/2005/8/2/Ask-a-Jedi-Working-with-SES-URLs-and-ColdFusion

    The first comment on this post contains an ISAPIRewrite Rewrite Rule sample (helpful only if you're on IIS, of course!). There are tons of Apache Rewrite samples out on the net. Just Google for "Apache Rewrite Rules Tutorial" and you'll get tons of hits. If you happen to be on a Java server, I can send you some samples (I had to setup these sort of rules for a site running Railo 3.1 on a Tomcat server).

    JosBVGAuthor
    Participant
    May 7, 2009

    Thank you very much for your reply.

    We are currently using an IIS server.

    We have looked into FuseBox before for security reasons. Would you recccomend FuseBox as quick fix to this solution.

    Also what are you opinions on how this will improve SEO, Will Search engine pick up the modified page names instead of the original version.

    Thanks

    Jos

    ilssac
    Inspiring
    May 7, 2009

    JosBVG wrote:

    Would you recccomend FuseBox as quick fix to this solution.

    Of all the advantages of the FuseBox MVC framework, I would NOT list quick fix as one.

    If you are starting a new project it would probably not be too difficult to incorporate.  But if you are converting an existing code base, quick is not going to apply.  It will be a real project to properly convert to the FuseBox methodolgy.