2 Replies Latest reply on Jul 3, 2007 7:02 PM by mgelber

    Confused: Can I do URL rewrite in Application.cfc?

    mgelber
      My current website uses old fashioned links like:
      mysite.com/topic.cfm/?id=600

      I'd like to rewrite them so they look like:
      mysite.com/topics/this-topic-is-interesting-600

      Note there is no ".cfm" in the new URL.

      Its easy enough to rewrite the links, but how do I handle the HTTP requests in application.cfc? I was assuming there was a variable I could set so that if the URL contained "topics/" I could tell CF to process topic.cfm .. but I can't find it.

      Do you need to intercept and parse the requests outside of CF?
        • 1. Re: Confused: Can I do URL rewrite in Application.cfc?
          Level 7
          Do you need to intercept and parse the requests outside of CF?

          Yes, in the web server; IIS, Apache, ect. Without the normal .cfm
          extension the request is not getting passed to the CF engine by the web
          server. You need to do the rewriting there so that the web server knows
          what to do with these types of requests.

          By the time the request has gotten to Application.cfm the system has
          determined that it is a coldFusion resource.

          Now a common middle ground would be URLS like
          mysite.com/topic.cfm/this-topic-is-interesting/600.

          This will get passed to ColdFusion and there is code out there that will
          process the extra 'directories' into the URL parameters they are meant
          to replace and use them as such.


          • 2. Re: Confused: Can I do URL rewrite in Application.cfc?
            mgelber Level 1
            Thank you Ian, I have it working now using one of the third-party URL rewriting packages.. I appreciate the help, you saved me hours (if not days) of frustration.