How to Run Your CGI Scripts outside CGI-BIN folder by .htaccess file

Common Gateway Interface is abbreviated to CGI. This is a standard way for web servers to interface executable scripts with end users. Those executable scripts or programs execute by this way and generate web pages dynamically.

CGI scripts are usually written in scripting language, but can be written in any programming language. Most of the hosts does not allow to execute those scripts outside the CGI-BIN folder on the public folder.

In order to run your cgi or perl scripts outside of cgi-bin folder. You need create a .htaccess file in the folder you want to run cgi or perl scripts. The following line should be in your .htaccess file:


AddHandler cgi-script .cgi
Options +ExecCGI

The first line tells the apache server to run cgi script in the folder, the second line tells apache server allow excute cgi scripts in this folder.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.