DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 8.1 Enabling a CGI Directory

Problem

You want to designate a directory that contains only CGI scripts.

Solution

Add the following to your httpd.conf file:

ScriptAlias /cgi-bin/ /www/cgi-bin/

Discussion

A CGI directory will usually be designated and enabled in your default configuration file when you install Apache. However, if you want to add additional directories where CGI programs are permitted, the ScriptAlias directive does this for you. You may have as many ScriptAlias'ed directories as you want.

The one line previously introduced is equivalent to these directive lines:

Alias /cgi-bin/ /www/cgi-bin/

<Location /cgi-bin/>
    Options ExecCGI
    SetHandler cgi-script
</Location>

Note that URLs that map to the directory in question via some other mechanism, such as another Alias or a RewriteRule, will not benefit from the ScriptAlias setting, as this mapping is by URL (<Location>), not by directory. As a result, accessing the scripts in this directory through some other URL path may result in their code being displayed rather than the script being executed.


See Also

    [ Team LiB ] Previous Section Next Section