URL rewriting on Hostek with IIS 7.5? Should PATH_INFO be blank?

1,032 views
Skip to first unread message

hofo

unread,
Jul 10, 2012, 10:37:14 PM7/10/12
to cfwh...@googlegroups.com
Hi,

Does anyone here use url rewriting on IIS with Hostek? None of my rewriting is working since I moved the code over there. It was working under Apache on my dev box so I know the routes are setup right. I changed the "enabled" attribute on the "ColdFusion on Wheels URL Rewriting" rule in the web.config. Is there anything else I have to do? Some other research says restart IIS to pickup web.config but I don't see that option in shared hosting :-). I've confirmed with Hostek that they are using the IIS7 URL Rewriting module.

I did notice in a dump of the CGI scope that PATH_INFO is empty. Doesn't URL rewriting depend on this?

Howard

tpet...@gmail.com

unread,
Jul 11, 2012, 8:43:54 AM7/11/12
to cfwh...@googlegroups.com
what version of coldfusion are you using? this is a known problem with iis7 and cf10.

Tim B

unread,
Jul 12, 2012, 10:15:28 AM7/12/12
to cfwh...@googlegroups.com
Just ran in to this. Its a know bug with Coldfusion 10 and IIS7 (They currently have no plans of fixing it).

Heres the bug:
https://bugbase.adobe.com/index.cfm?event=bug&id=3209090

I found a temporary fix at http://www.giancarlogomez.com/2012/06/you-are-not-going-crazy-cgipathinfo-is.html

Assuming your on 1.1.8, open "wheels/global/internal.cfm" and on line 235 break and add the following code:
    if (structKeyExists(cgi,"http_x_rewrite_url") && len(cgi.http_x_rewrite_url)) // iis6 1/ IIRF (Ionics Isapi Rewrite Filter)
        request.path_info = listFirst(cgi.http_x_rewrite_url,'?');
        else if (structKeyExists(cgi,"http_x_original_url") && len(cgi.http_x_original_url)) // iis7 rewrite default
        request.path_info = listFirst(cgi.http_x_original_url,"?");
        else if (structKeyExists(cgi,"request_uri") && len(cgi.request_uri)) // apache default
        request.path_info = listFirst(cgi.request_uri,'?');
        else if (structKeyExists(cgi,"redirect_url") && len(cgi.redirect_url)) // apache fallback
        request.path_info = listFirst(cgi.redirect_url,'?');
        else // fallback to cgi.path_info
        request.path_info = cgi.path_info;
       
        // finally lets remove the index.cfm because some of the custom cgi variables don't bring it back
        // like this it means at the root we are working with / instead of /index.cfm
        request.path_info = replace(request.path_info,'index.cfm','');
        request.cgi.path_info = request.path_info;     

        loc.returnValue.path_info = request.cgi.path_info;   

Let me know if this works for you.

Tim B

unread,
Jul 12, 2012, 10:21:26 AM7/12/12
to cfwh...@googlegroups.com
@CFWheels team - Is there a less obtrusive way of doing this, like from the controller level or something. I hate touching CFWheels core unless its required. And if it is required then it should probably ship with the latest build since this is a serious issue with no likely fix from Adobe.

Thoughts?

tpet...@gmail.com

unread,
Jul 12, 2012, 2:37:31 PM7/12/12
to cfwh...@googlegroups.com
Two ways to do this:

Create a plugin for the fix. Perferred so that others caninstall it and test it out to make sure that it works.

Just override the method in the controller.cfc.

either way could you please sumbit a pull request to the github repo so we can merge it after we test it.

Brian Lang

unread,
Aug 10, 2012, 8:20:06 PM8/10/12
to cfwh...@googlegroups.com
This code worked for me on Hostek, but not on OS X Lion.
Something's not quite right in the rewrite bits for me... Can anyone shed some light??

~Brian

Brian Lang

unread,
Aug 13, 2012, 1:02:24 PM8/13/12
to cfwh...@googlegroups.com
I fiddled with the code provided previously, and did some dumps and logging to figure out what was going on.

I am running MAMP on OS X Lion. So it's maybe not a standard Apache implementation.

I first logged to see which variant of request.path_info was being selected, and it came back that the "apache default" option was running.
When I dumped the CGI struct though, there was no key "request_uri" being displayed. So I logged that too, and found it contained '/rewrite.cfm/home'
This was NOT working - I was getting an error page.
So I modified the code in the "apache default" section to read:
            request.path_info = cgi.path_info;
This solved the problem on MAMP on OS X Lion.

Hope this helps someone else.


~Brian

Andy Bellenie

unread,
Aug 15, 2012, 6:26:48 AM8/15/12
to cfwh...@googlegroups.com
Nice work Brian, glad you solved it and thanks for posting the solution to the group.

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/iUwUHgZqgbgJ.

To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Brian Lang

unread,
Sep 5, 2012, 2:01:09 PM9/5/12
to cfwh...@googlegroups.com
UPDATE:

The CF10.0.1 patch is supposed to fix this problem. As soon as I get a chance to get it installed on our Hostek VPS, I will let you know whether or not it takes care of this.

Ben Riordan

unread,
Sep 10, 2012, 12:49:16 PM9/10/12
to cfwh...@googlegroups.com
I've had the 10.0.1 patch installed on hostek shared hosting since last week and it has been working just fine for me.

Brian Lang

unread,
Oct 30, 2012, 1:03:18 PM10/30/12
to cfwh...@googlegroups.com
Another update.

I setup a new website today (Oct. 30) on a brand-new, fresh, fully patched server.
Web Server: Windows 2008 with IIS 7.5. URL Rewrite module installed.
CF 10 fully patched with both the Mandatory update and Update 2.

I had to add the code (provided by Tim B above) after line 235 of /wheels/global/internal.cfm to get the URL Rewriting to work properly.


        if (structKeyExists(cgi,"http_x_rewrite_url") && len(cgi.http_x_rewrite_url)) // iis6 1/ IIRF (Ionics Isapi Rewrite Filter)
            request.path_info = listFirst(cgi.http_x_rewrite_url,'?');
        else if (structKeyExists(cgi,"http_x_original_url") && len(cgi.http_x_original_url)) // iis7 rewrite default
            request.path_info = listFirst(cgi.http_x_original_url,"?");
        else if (structKeyExists(cgi,"request_uri") && len(cgi.request_uri)) // apache default
            request.path_info = cgi.path_info;

Brad P.

unread,
Nov 6, 2013, 7:28:26 PM11/6/13
to cfwh...@googlegroups.com

Hello everyone,

I’m having the trouble getting the URL rewrite to work on my laptop. I’m just installed ColdFusion 10 on Windows 7 IIS7 and found that the URL rewrite no longer works. I’ve found several related issue but none worked for me. Here's what I've tried...

  •  Installed ColdFusion 10,0,11,285437
  • Install URL Rewrite module for iis
  • Setup a brand new CFWheels 1.1.8 app
  • I’ve set  <cfset set(UrlRewriting="on")> in /config/settings.cfm
  • I’ve uncomment rewrite section in the web.cofig

<rules>
<rule name="ColdFusion on Wheels URL Rewriting" enabled="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{SCRIPT_NAME}" negate="true" pattern="^/cfwheels118/(flex2gateway|jrunscripts|cfide|CFFileServlet|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$)" />
</conditions>
<action type="Rewrite" url="/cfwheels118/rewrite.cfm/{R:1}" />
</rule>
</rules>

I get this error:

Could not find the view page for the index action in the Cfwheels118 controller.

When I tried Tim Badolato script:

 

         if (structKeyExists(cgi,"http_x_rewrite_url") && len(cgi.http_x_rewrite_url)) // iis6 1/ IIRF (Ionics Isapi Rewrite Filter)

                request.path_info = listFirst(cgi.http_x_rewrite_url,'?');

          else if (structKeyExists(cgi,"http_x_original_url") && len(cgi.http_x_original_url)) // iis7 rewrite default

                request.path_info = listFirst(cgi.http_x_original_url,"?");

          else if (structKeyExists(cgi,"request_uri") && len(cgi.request_uri)) // apache default

                request.path_info = listFirst(cgi.request_uri,'?');

          else if (structKeyExists(cgi,"redirect_url") && len(cgi.redirect_url)) // apache fallback

                request.path_info = listFirst(cgi.redirect_url,'?');

          else // fallback to cgi.path_info

            request.path_info = cgi.path_info;

          

            // finally lets remove the index.cfm because some of the custom cgi variables don't bring it back

            // like this it means at the root we are working with / instead of /index.cfm

            request.path_info = replace(request.path_info,'index.cfm','');

            request.cgi.path_info = request.path_info;    

 

            loc.returnValue.path_info = request.cgi.path_info; 


I'm I missing a step? Any insights would be GREATLY appreciated.

Regards,

Brad P.

unread,
Nov 7, 2013, 1:21:29 AM11/7/13
to cfwh...@googlegroups.com
Just wanted to post an update. I was able to get it work with the method posted. However I had to create a new website in IIS and removing "/cfwheels118" in the rewrite section in the web.cofig. At this point I'm going to uninstall CF10 and reinstall CF9.

Thanks,


On Tuesday, July 10, 2012 7:37:14 PM UTC-7, hofo wrote:

Brent Alexander

unread,
Apr 18, 2014, 9:48:26 AM4/18/14
to cfwh...@googlegroups.com
This worked for me...

https://groups.google.com/forum/#!topic/cfwheels/v1Rj3DgdR78

I fixed this in 1.1.8 by replacing the function in \wheels\global\internal.cfm line 227 with the code below:

<cffunction name="$cgiScope" returntype="struct" access="public" output="false" hint="This copies all the variables Wheels needs from the CGI scope to the request scope.">
    <cfargument name="keys" type="string" required="false" default="request_method,http_
x_requested_with,http_referer,server_name,path_info,script_name,query_string,remote_addr,server_port,server_port_secure,server_protocol,http_host,http_accept,content_type,http_x_rewrite_url,http_x_original_url,request_uri,redirect_url">
    <cfargument name="scope" type="struct" required="false" default="#cgi#">
    <cfscript>
        var loc = {};
        loc.returnValue = {};
        loc.iEnd = ListLen(arguments.keys);
        for (loc.i=1; loc.i <= loc.iEnd; loc.i++)
        {
            loc.returnValue[ListGetAt(arguments.keys, loc.i)] = arguments.scope[ListGetAt(arguments.keys, loc.i)];
        }
       

        /* Fixes IIS issue that returns a blank cgi.path_info
           Fix: http://www.giancarlogomez.com/2012/06/you-are-not-going-crazy-cgipathinfo-is.html
           Bug: https://bugbase.adobe.com/index.cfm?event=bug&id=3209090
        */
        if (!Len(loc.returnValue.path_info))
        {
            if (Len(loc.returnValue.http_x_rewrite_url))
            {// iis6 1/ IIRF (Ionics Isapi Rewrite Filter)
                loc.returnValue.path_info = ListFirst(loc.returnValue.http_x_rewrite_url,'?');
            }
            else if (Len(loc.returnValue.http_x_original_url))
            {// iis7 rewrite default
                loc.returnValue.path_info = ListFirst(loc.returnValue.http_x_original_url,"?");
            }
            else if (Len(loc.returnValue.request_uri))
            {// apache default
                loc.returnValue.path_info = ListFirst(loc.returnValue.request_uri,'?');
            }
            else if (Len(loc.returnValue.redirect_url))
            {// apache fallback
                loc.returnValue.path_info = ListFirst(loc.returnValue.redirect_url,'?');

            }
        }
           
        // finally lets remove the index.cfm because some of the custom cgi variables don't bring it back
        // like this it means at the root we are working with / instead of /index.cfm
        if (Len(loc.returnValue.path_info) gte 10 && Right(loc.returnValue.path_info, 10)  eq "/index.cfm")
        {// this will remove the index.cfm and the trailing slash
            loc.returnValue.path_info = Replace(loc.returnValue.path_info,'/index.cfm','');
            if (!Len(loc.returnValue.path_info))
            {// add back the forward slash if path_info was "/index.cfm"
                loc.returnValue.path_info = "/";
            }
        }
    </cfscript>
    <cfreturn loc.returnValue>
</cffunction>


On Tuesday, July 10, 2012 7:37:14 PM UTC-7, hofo wrote:
Reply all
Reply to author
Forward
0 new messages