Name
ScriptAlias
Synopsis
ScriptAlias URLpath CGIpath
Server config, virtual host
The ScriptAlias
directive does two things. It sets
Apache up to execute CGI scripts, and it converts requests for URLs
starting with URLpathto
execution of the script in CGIpath.
For
example:
ScriptAlias /bin /usr/local/apache/cgi-bin
An incoming URL like
www.butterthlies.com/bin/fred will run the script
/usr/local/apache/cgi-bin/fred
.
Note that CGIpath
must be an
absolute path, starting at /.
A very useful feature of ScriptAlias
is that the
incoming URL can be loaded with fake subdirectories. Thus, the
incoming URL
www.butterthlies.com/bin/fred/purchase/learjetwill run .../fred
as
before, but will also make the text
purchase/learjet available to
fred
in the environment variable
PATH_INFO
. In this way you can write a single
script to handle a multitude of different requests. You just need to
monitor the command-line arguments at the top and dispatch the
requests to different subroutines.
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.