<p>The example shown is from your default <code>httpd.conf</code>
configuration file, if you installed Apache in the default
location. The <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
directive is much like the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive, which defines a URL prefix that
is to mapped to a particular directory. <code class="directive">Alias</code>
and <code class="directive">ScriptAlias</code> are usually used for
directories that are outside of the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directory. The difference between
<code class="directive">Alias</code> and <code class="directive">ScriptAlias</code>
is that <code class="directive">ScriptAlias</code> has the added meaning
that everything under that URL prefix will be considered a CGI
program. So, the example above tells Apache that any request for a
resource beginning with <code>/cgi-bin/</code> should be served from
the directory <code>/usr/local/apache/cgi-bin/</code>, and should be
is requested, Apache will attempt to execute the file
<code>/usr/local/apache/cgi-bin/test.pl</code>
and return the output. Of course, the file will have to
exist, and be executable, and return output in a particular
way, or Apache will return an error message.</p>
<h3><a name="nonscriptalias" id="nonscriptalias">CGI outside of ScriptAlias directories</a></h3>
<p>CGI programs are often restricted to <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>'ed directories for security reasons.
In this way, administrators can tightly control who is allowed to
use CGI programs. However, if the proper security precautions are
taken, there is no reason why CGI programs cannot be run from
arbitrary directories. For example, you may wish to let users
have web content in their home directories with the
If they want to have their own CGI programs, but don't have access to
the main <code>cgi-bin</code> directory, they will need to be able to
run CGI programs elsewhere.</p>
<h3><a name="options" id="options">Explicitly using Options to permit CGI execution</a></h3>
<p>You could explicitly use the <code class="directive"><a href="../mod/core.html#options">Options</a></code> directive, inside your main server configuration
file, to specify that CGI execution was permitted in a particular
<p>The above directive tells Apache to permit the execution
of CGI files. You will also need to tell the server what
files are CGI files. The following <code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code> directive tells the server to treat all
files with the <code>cgi</code> or <code>pl</code> extension as CGI