2 Replies Latest reply on Apr 18, 2014 7:38 AM by cewyattjr

    Redirecting an entire folder w/IIS 7.5 and CF10

    cewyattjr

      I know that in past versions of CF and IIS, I've been able to redirect an entire folder such that 404 request to www.domain.edu/folder/filename.cfm would simply redirect.  However now it seems like if the request is for a CFM, IIS ignores this, and hands it off to ColdFusion's 404 template, completely bypassing the redirect directive in the web.config for a given directory.  This is creating more 404's than previously because we had actually successfully managed them using folder redirects in the IIS admin tool.

       

      I wonder if others have suggestions on how to handle.  I know that another way is simply to "sniff" for the 404 path that is passed to the CF 404 template.  That's proved to be challenging as well, since the latest version of CF doesn't seem to carry through that query string/referer to the 404 page.

       

      I'd rather handle it all in IIS and I wonder if anyone has successfully done this with CF 10 and IIS 7.5 or 8.0?

       

      Thank you!

       

      Chuck Wyatt

        • 1. Re: Redirecting an entire folder w/IIS 7.5 and CF10
          haxtbh Level 4

          I have had issues myself with CF10 and 404 pages. I believe there is a bug at the moment with IIS and 404 redirects.

           

          I found this quite helpful:

           

          http://stackoverflow.com/questions/18694932/coldfusion-10-iis-non-existant-urls-that-are-c fm-files-retrieving-original-u

          • 2. Re: Redirecting an entire folder w/IIS 7.5 and CF10
            cewyattjr Level 1

            So I've got this route, see web.config code below.  When I plug this into the root web.config on our site it does work... for a time.  Then within about 20 minutes the entire server craps out.  The average response time drops to zero and it stops serving out anything but completely blank pages.    I've tried this on two occasions over a month time span the same results -- it works for a bit, and happily transfers those 404 query strings and about 20-30 minutes later the server is no longer available.

             

            Seems like not a good solution for us, unless I can discover what causes the outage.  Nothing obvious in the event logs.

             

            Chuck

             

             

            <httpErrors>

                        <remove statusCode="404" subStatusCode="-1" />

                    </httpErrors>

                    <rewrite>

                        <rules>

                            <rule name="404 HTTP">

                                <match url="(.*)" />

                                <conditions>

                                    <add input="{REQUEST_URI}" pattern="(.*)css" negate="true" />

                                                                  <add input="{REQUEST_URI}" pattern="(.*)js" negate="true" />

                                                                 

                                                                        <add input="{REQUEST_URI}" pattern="CFFileServlet/(.*)" negate="true" />

                                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

                                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

                                    <add input="{SERVER_PORT_SECURE}" pattern="0" />

                                </conditions>

                                <action type="Rewrite" url="/referenceinfo.cfm?404;http://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}" />

                            </rule>

                                                    <rule name="404 HTTPS">

                                <match url="(.*)" />

                                <conditions>

                                          <add input="{REQUEST_URI}" pattern="(.*)css" negate="true" />

                                                                        <add input="{REQUEST_URI}" pattern="(.*)js" negate="true" />

                                                                  <add input="{REQUEST_URI}" pattern="CFFileServlet/(.*)" negate="true" />

                                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

                                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

                                    <add input="{SERVER_PORT_SECURE}" pattern="1" />

                                </conditions>

                                <action type="Rewrite" url="/referenceinfo.cfm?404;https://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}" />

                            </rule>

                        </rules>

                    </rewrite>