Apache Does Note Populate CGI.PATH_INFO with ColdFusion

I just started using Apache for local ColdFusion 8 development and while this might be well know by most, I recently learned about it and so am making a note of it.

Apps that use CGI.PATH_INFO should be changed to use CGI.SCRIPT_NAME, because Apache does not support CGI.PATH_INFO.

It is also recommended to use CGI.HTTP_HOST rather than CGI.SERVER_NAME, because server_name can be incorrect on multi-homed servers.

Comments
Greg Fuller's Gravatar Hmmm. I'm on Apache 2.2.4 on WinXP and cgi.path_info works. It holds the part of the URL that comes after the template. For example, for http://mysite.com/index.cfm/good/stuff, it would show /good/stuff. Using mod_rewrite, the url is http://mysite.com/good/stuff, and cgi.path info is likewise /good/stuff.

If it doesn't work like this in other Apache environments, I'd sure be interested in knowing.
# Posted By Greg Fuller | 8/17/07 6:51 PM
Jim Pickering's Gravatar From what I've read on the web, it seems to be a pretty well known fact, amongst the ColdFusion community using Apache that cgi.path_info has never worked. Perhaps it works when using other technologies. I will change the title of the blog entry to be a bit more accurate.
# Posted By Jim Pickering | 8/17/07 11:01 PM
Greg Fuller's Gravatar What do you mean by other technologies? I'm on CF 8, Apache 2, WinXP, and it works as I stated.

CGI.Path_Info is also used in 5 different templates in Ray Camden's popular BlogCFC.

Does it not work under other versions of Apache, or other OS's?
# Posted By Greg Fuller | 8/17/07 11:52 PM
Jim Pickering's Gravatar I'm using WinXP SP2, Apache 2.2.4, and ColdFusion 8 Dev Edition. CGI.Path_Info is empty - and consistently empty across 4 other WinXP SP2 notebooks at our office, when testing the same apps. When the same apps are browsed from our dev server using IIS, cgi.path_info works correctly.

It's a mystery to me why it works for you, but not for me and others. But the alternatives I blogged do work.
# Posted By Jim Pickering | 8/18/07 12:13 AM
Greg Fuller's Gravatar Jim, this is a mystery. Maybe this is it:

cgi.path_info is empty for me too unless there is something after the .cfm template name. If you browse to 'yoursite.com/whatever.cfm/hello/world,' cgi.path_info for me is '/hello/world'. This is extremely helpful when using mod_rewrite, because you can hide the 'whatever.cfm'(usually index.cfm), and program your own ses url routing.

If I browse to 'mysite.com/whatever.cfm,' the cgi.path_info is empty.

Which url pattern are you using, 'yoursite.com/whatever.cfm,' or 'yoursite.com/whatever.cfm/hello' ?

Thanks for your patience. I'm really wondering what's going on here.
# Posted By Greg Fuller | 8/18/07 2:30 AM
Jim Pickering's Gravatar Greg, those targets popped up because you typed http colon slash slash - a feature of BlogCFC I guess. I cleaned them up.

I am using .cfm in my paths throughout my sites, so what you have discovered is that cgi.path_info is empty with Apache when using .cfm in the path, but if using .cfm/hello type paths, it works.

That's good to know. So we're changing cgi.path_info on our sites to cgi.script_name, because we're doing local development with Apache.

Thanks.
# Posted By Jim Pickering | 8/24/07 10:49 AM
Rielter's Gravatar Hi, my name is Christ Voip. It is good that someone writes articles which really matters something. Thank you for this article, it’s full of knowledge which is hard to find in tons of rubbish in our famous world wide web. Regards and good luck! http://rielter.org/ Chris
# Posted By Rielter | 1/28/08 11:22 PM
Jason's Gravatar I have been having the same problem however it has expanded. I was working on an application that relied heavily on cgi.path_info and it was working on Win XP2 with CF7 however after leaving off the project for several months switching computers and installing cf8 it has not worked for me. I've tried it on a mac with apache, and on windows with a cf8 stand alone server install. Could this be not a server thing but a CF version thing? What version of CF are you running Greg? Maybe that could be the difference rather than server platform.

Jason
# Posted By Jason | 6/27/08 11:30 PM
Copyright ©2007 JimPickering.com. Some rights reserved. BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.