Special use for error pages or self-made
directory listings (PHP >= 4.3.3)
You can use PHP to generate the error pages for
"404 Not Found" or similar. Add the following line to
the object in obj.conf for every error page you want to overwrite:
| Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...] |
where XXX is the HTTP error code. Please delete any other Error directives which could interfere with yours. If you want to place a page for
all errors that could exist, leave the code parameter out. Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
Another possibility is to generate self-made
directory listings. Just create a PHP script which displays
a directory listing and replace the corresponding default
Service line for type="magnus-internal/directory" in obj.conf with the following:
| Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...] |
For both error and directory listing pages the original
URI and translated URI are in the variables $_SERVER['PATH_INFO']
and $_SERVER['PATH_TRANSLATED'].
Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make subrequests on the webserver and insert the result in the webpage.
The problem is, that this function uses some undocumented
features from the NSAPI library.
Under Unix this is not a problem, because the
module automatically looks for the needed functions and
uses them if available. If not, nsapi_virtual() is disabled.
Under Windows limitations in the DLL handling
need the use of a automatic detection of the most recent
ns-httpdXX.dll file. This is tested for servers till version 6.1. If a newer version of the
SunONE server is used, the detection fails and nsapi_virtual() is disabled.
If this is the case, try the following: Add the
following parameter to php4_init in magnus.conf/obj.conf:
| Init fn=php4_init ... server_lib="ns-httpdXX.dll" |
where XX is the correct DLL version number. To get it, look
in the server-root for the correct DLL name. The DLL with
the biggest filesize is the right one.
You can check the status by using the phpinfo() function.
Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!