From the documentation on the exec
element:
The CGI script is given the PATH_INFO and query string (QUERY_STRING) of the original request from the client; these cannot be specified in the URL path. The include variables will be available to the script in addition to the standard CGI environment.
...
The include virtual element should be used in preference to exec cgi. In particular, if you need to pass additional arguments to a CGI program, using the query string, this cannot be done with exec cgi, but can be done with include virtual, as shown here:
<!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
There are two options that could be taken:
- Use the
404.php
script via the existing<!--#exec cgi
element. It should be able to use the relevant CGI variables immediately (e.g.$_SERVER['REQUEST_URI']
). - Change to use an
<!--#include virtual
element and pass in the required variables.
Personally, I'd go with the first option.