Recipe 8.1 Enabling a CGI Directory


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


Add the following to your httpd.conf file:

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


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

  • Chapter 5

  • Recipe 8.2


Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: