Skip navigation
Currently Being Moderated

ColdFusion with IIS URL Rewrite - Page never finishes loading

Sep 16, 2013 3:36 PM

Tags: #cf10 #iis7.5 #url_rewrite

I am running CF10 on IIS 7.5 with URL Rewrite module installed.


All the rewrite rules work perfectly and ColdFusion is returning the correct pages. In order to get the page displayed in the browser I have to manually set the 'content-length' value in Application.cfc like this:



<cffunction name="onRequestEnd">

<cfheader name="Content-Length" value="#getPageContext().getCFOutput().getBuffer().size()#" />




Without this code the browser does not display the page. However, even though it is now displaying the page, it is not doing it correctly. The page never finishes loading fully and not all of the HTML content seems to be on the page.

I have tried to add a <cfflush> tag after setting the 'content-length' but it makes no difference. I don't understand why this is happening but I know that it has happened to someone else who was using htaccess: -loading-coldfusion-and-htaccess-bug-575906.html


Can anyone please help?

  • Currently Being Moderated
    Sep 17, 2013 1:00 AM   in reply to solaced

    Try installing ISAPI rewrite Lite (free) and see if it works with that. We use it with CF 10/IIS 8 and it works great. if it works, it looks to be an issue with your rewriter module.

    Mark as:
  • Currently Being Moderated
    Sep 17, 2013 8:57 AM   in reply to solaced

    I also tried Ape and it did not work for us on the first attempt, so I went back to using Helicon. Their product is also very well supported and documented, which is a major reason for using it.

    Mark as:
  • Currently Being Moderated
    Sep 17, 2013 11:52 AM   in reply to solaced

    Did moving to Helicon ISAPI Rewrite help anything?  I would be surprised if it did.  I used to use that, but had to ditch it and now use just the Rewrite module built-in to IIS 7.5.  Why do you have to force the content length anyway?  That seems like a big potential break point.


    Also, I am not aware of a program that will re-write the existing links embedded in your HTML code, if that is what you're asking.  Of course if those links are in a content field that you can manipulate with ColdFusion beforehand, then you can customize those links using CF however you want.


    P.S.  The IIS7 Rewrite module has example templates built-in that should show you how to craft a custom response to any scenario, or at least ge the ideas flowing.  They are under the SEO section of the "Add rule" dialog.  The "User-friendly" mapping should all give you ideas.

    Mark as:
  • Currently Being Moderated
    Sep 17, 2013 12:06 PM   in reply to solaced

    Okay, I didn't know that.  I'm surprised the IIS Rewrite is able to change the HTML code in your page before someone even clicks the link, wow.  I don't use Outbound obviously.


    Content field, as in if you are using a content management system, and the field in the database contains the entire "body" of the page, then maybe you could write some fancy ColdFusion code to rewrite (Replace/REReplace) things it found before displaying to the end-user.

    Mark as:
  • Currently Being Moderated
    Sep 17, 2013 2:42 PM   in reply to David-Smith

    ISAPI rewrite does not (can not) change the physical HTML code, but what it can do is convert the request into something else. For example we have links like this:


    <a href="/widgets.cfm">Widgets</a>

    <a href="/gizmos.cfm">Gizmos</a>


    and in our rewrite rule file, we have:


    RewriteRule ([^\?]*)/widgets.cfm$ $1/categorypage.cfm?id=100 [L,QSA]

    RewriteRule ([^\?]*)/gizmos.cfm$ $1/categorypage.cfm?id=101 [L,QSA]



    So that a request for actually requests, so in other words, we have SEO friendly URLs like widgets.cfm instead of URLs with parameters (?id=) in them. That is how the URL is "rewritten" in this context. Both URLs would work, but we never expose the one with the parameters to the end-user. URL rewriting is an entire subject in its own right, and is not directly related to ColdFusion as it works with all server-side languages.


    Solaced, can you give an example of the URLs you are working with, and what you need the outcome to be?

    Mark as:
  • Currently Being Moderated
    Sep 18, 2013 3:21 AM   in reply to solaced

    Solaced, I can put the friendly URLs in my HTML code and they work fine (with Helicon's ISAPI rewrite using the rules I pasted earlier), indeed that is the most preferable method since we clearly want the friendly URLs to be seen by the public.


    I can put the long URL or the friendly URL in my source, and both work fine. Clearly I want the unfriendly URL to stay out of the Google index if possible (for SEO).  The only time a friendly URL will not work is when the rewrite for it is removed.

    Mark as:
  • Currently Being Moderated
    Sep 18, 2013 7:56 AM   in reply to solaced

    My advice is to use a different link checker service, one that pings the links from outside your application, i.e., after everything has been rendered.  DW will never work in this case.

    Mark as:
  • Currently Being Moderated
    Sep 18, 2013 8:52 AM   in reply to solaced

    Solaced, I've never used an IDE; I only code with notepad.


    Orphaned links (and other link issues) are best checked with Google Webmaster Tools (GWT). There's a whole raft of tools that can help you there, and they are free. As DCwebguy says, there are literally dozens of tools for checking website links for 404 errors and redirects etc. Our e-commerce site has over 30,000 products and lots of links and we use GWT and Google Analytics to track visits and deal with errors etc.


    On one project I wrote CFML code to check when a product 404'd and then either 301'd it to a new alternative page, or show a range of alternatives. This was useful for when a product name changed, which happens very frequently for us. There are many ways to deal with broken links both on-and off-site and you can automate and log a lot of it internally.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points