If you copy the PHP4 binaries (for Windows php4.exe and the php4ts.dll) into the folder .\Pi3Web\Cgi-Bin\ you can run PHP scripts from any folder with a valid URL mapping. This is possible using the standard configuration by calling e.g. http://localhost/cgi-bin/php.exe/pidocs/features/test3.php. This is very easy to achieve, but doen't allow an URL formed like e.g. http://localhost/pidocs/features/test3.php. In the next section we will learn, how this could be achieved by a few configuration changes.
We assume, PHP is installed in C:\PHP4 and our PHP files are stored in WebRoot. You've to change some of the existing configuration objects and to add a new PHP4Mapper object. Apply the following changes using a text editor to your Pi³Web configuration file (.\Pi3Web\Conf\Config.pi3 or .\Pi3Web\Conf\Features.pi3). First we've to change the Start object to add the appropriate mapping:
<Object> Name Start Class FlexibleHandlerClass ... Mapping Condition="&or(®exp('*.php',$U),®exp('*.php',$f))" Php4Mapper From="/" To="WebRoot\" ... </Object>
Now add a new PathMapper object called 'Php4Mapper':
<Object> Name Php4Mapper Class PathMapperClass ... Action "&dbreplace(response,string,ObjectMap,Scripts)" Action "&dbreplace(response,string,PathInfo,&dblookup(response,string,ScriptName))" Action "&dbreplace(response,string,PathTranslated,&dblookup(response,string,Path))" ... </Object>
Finally the StandardCGI handler has to be extended in order to add the appropriate command line mapping:
<Object> Name StandardCGI Class CGIClass ... CommandLineByExt .php="c:\\PHP4\\php.exe %p %q" ... </Object>
A special point is the way, how the CGI environment variables PATH_INFO and PATH_TRANSLATED are set. The CGI program needs the PATH_TRANSLATED environment to find the script to be parsed. Otherwise you must compile PHP4 with the --enable-discard-path option.