I’d like to have a cgi script live in my home dir at a location other than inside of my web hosting dir. For example, say I want my script to live in ~/bin/foo.pl, rather than ~/mydomain.com/cgi-bin/foo.pl. Is there some way to tell Apache to look for cgi scripts at a location that is not relative to the web root?
Short answer: No. Apache will only look inside your document root. However, Apache will look anywhere within your document root for scripts to run, so you don’t have to put your scripts inside cgi-bin unless you want to.
Longer answer: Is there some reason you’re trying to do this? If you can explain what kind of result you’re looking for, one of us might be able to give you a better idea how to accomplish it.
Programmer’s answer: There is always a way
I will be sharing the same script across multiple domains, and would rather not have to maintain copies. Having the script in a common place is less fragile to version inconsistency.
Also, I was keen to share code between the cgi script and my .procmail response script, since they both collude to provide a related service. It just feels wrong to me to point my .procmail code at ~/mydomain.com/cgi-bin/foo.pl, since that entry point is agnostic of which domain I am using.
I suppose I can use some clever wonking in the .htaccess file for the root to re-map the cgi-bin sub-directory of the document root to a different directory in my home dir?