ssishtml

.shtml - how to redirect AND pass the URI


on my shared server, I'm trying to create a custom 404 page. This particular host uses SHTML, and I cannot ReWrite..

I can display the uri:

<!--#echo var="REQUEST_URI" -->

I can make the URI a part of a variable:

<!--#set var="URI" value="404.php?xxx=$REQUEST_URI" -->

I can redirect to my own 404.php page:

<!--#exec cgi="404.php" -->

but I can't seem to put the URI variable's value into the redirect. None of these work:

<!--#exec cgi="404.php?xxx=$REQUEST_URI" -->

<!--#exec cgi="$URI" -->

<!--#exec cgi="URI" -->

any ideas that will work? Thanks in advance.


Solution

  • 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:

    Personally, I'd go with the first option.