Exec
rule to allow scripts
httpd
versions 2.15 and newer have
two script interfaces. The other one is the official
CGI,
Common Gateway Interface, which enables scripts to be shared
between different server implementations (NCSA server, Plexus, etc).
The other one is the original, very easy-to-use, interface, that was
introduced in version 2.13. Use of CGI instead of the old interface is strongly encouraged.
IMPORTANT: If you have, or wish to write, scripts
that use the old interface, your script name has to end in
.pp
suffix (comes from "Pre-Parsed"). URLs referring to
these scripts should not contain this suffix. This is to make it
easier to later upgrade to CGI scripts, so you only need to change
the script name in the file system, and not the documents pointing to
it. If you absolutely want to use the old interface (which is nice
for quick hacks that don't need to be portable), see the doc.
(/etc/httpd.conf)
by Exec
rules:
Exec /url-prefix/* /physical-path/*Where /url-prefix/ is the special string that signifies a script request, and /physical-path/ is the absolute filesystem pathname of the directory that contains your scripts.
Exec /htbin/* /usr/etc/cgi-bin/*makes URL paths starting with
/htbin
to be mapped to
scripts in directory /usr/etc/cgi-bin.
I.e.
requesting
/htbin/myscriptcauses a call to script
/usr/etc/cgi-bin
httpd
versions before 2.15 there was an
HTBin
directive:
HTBin /physical-pathwhich is now obsolite, but understood by the server to mean
Exec /htbin/* /physical-path/*Use of
Exec
rule instead is recommended for its
generality.
POST
method). Search scripts get
keywords also as command
line arguments. Most important environment variables are:
QUERY_STRING
+ =
&
have a special meaning.
The contents of this variable can be easily parsed using the
cgiparse
program.
PATH_INFO
Exec
rule:
Exec /htbin/* /usr/etc/cgi-bin/*a URL with path
/htbin/myscript/extra/pathinfowill execute the script
/usr/etc/cgibin/myscript
with PATH_INFO
environment variable set to
/extra/pathinfo
.
PATH_TRANSLATED
Content-Type:
line giving
the document content type, followed by an empty line.
The actual document follows the empty line.
Example:
Content-Type: text/html <HEAD> <TITLE>Script test> </HEAD> <BODY> <H1>My First Virtual Document</H1> .... </BODY>
Location:
header followed by an empty line:
Example:
Location: http://info.cern.ch/hypertext/WWW/TheProject.htmlThis causes the server to send a redirection to client, which then retrieves that document. If
Location
starts with a slash
(is not a full URL), it is taken to be a virtual path for a document
on the same machine, and server passes this string right away through
the rule system and serves that document as if it had been requested
in the first place. In this case clients don't do the redirection,
but the server does it "on the fly". Example:
Location: /hypertext/WWW/TheProject.htmlUnderstand, that this is a virtual path, so after translations it might be, for example,
/Public/Web/TheProject.html
.
Important: Only full URLs in
Location
field can contain the #label part of URL,
because that is meant only for the client-side, and the server cannot
possibly handle it in any way.
nph-
prefix. This makes httpd
connect
script's output stream directly to requesting client reducing the
overhead of server needlessly parsing the response headers.
HTTP/1.0 200 Script results follow Server: MyScript/1.0 via CERN/3.0 Content-Type: text/html <HEAD> <TITLE>Just testing...</TITLE> </HEAD> <BODY> <H1>Output From NPH-Script</H1> Yep, seems to work. </BODY>
Search
directive in the configuration
file givin the absolute pathname of the script
performing the search:
Search /absolute/path/searchEvery time a document is searched, this script is called with
argv[1]
, argv[2]
, ...
QUERY_STRING
PATH_INFO
PATH_TRANSLATED
Content-Type: text/html ...generated document...