From a technical perspective, there's no reason at all. In fact, some webservers allow you to have your CGI scripts (which don't necessarily have to be written in Perl) on another machine.
The primary reason most people separate it is to have a separation of concerns - you don't want your business logic mixed in with your display logic.
The other reason most commonly cited is that it's easier to lock down your cgi-bin directory than it is your htdocs directory. So, there's a small security gain, but not a lot.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] |
I'm guessing that historically, cgi files had to be in the cgi-bin directory. Nowadays, at least with Apache, it's just a question of preference. One of the directories on my server is configured such that .jpg files are treated as CGI files. (They're actually perl scripts that generate images, not images.)
| [reply] |
you can but the purpose (at least for me) to use cg-bin is to have a central location for all of your cgis. This makes it easier to re-use scripts common to multiple pages throughout your site. Also nice because you can lock it to protect the scripts.
-CSUhockey3
| [reply] |
you can place your script anywhere you want. just make sure the webserver you use will execute them.
The reason is to keep script separately from html just to be more organized. Sometimes security. In reality usually scripts can easily access the directory with html files as they are run by the webserver under the same user.
I keep scripts in the same directory where I keep html files. Blame me other monks, if you think it's not correct. | [reply] |
no blame -- to each his own I guess. I just prefer the organization and customization of cgi-bin. Especially when the number of scripts gets out of control.
| [reply] |