One of the least leveraged features of IIS is the IIsWebFile, which can work absolute wonders within the proper configuration, as I will shortly show...
I have a CGI script (in perl) in a cgi-bin directory. I want to be able to run that script from the root of the site without the user seeing the ugly URL.
I don't want to make the root directory executable.
Instead of: http://www.mysite.com/cgi-bin/script.cgiI want: http://www.mysite.com/
I tried putting a Server.Transfer in index.asp but that didn't seem to like calling non-asp.
I am using a 3rd party host so don't have a lot of control although they would likely change settings if I asked.
Any pointers would be greatly appreciated.
Thanks in advance,
IIS supports this behavior intrinsically without needing external plugins nor ASP pages. All you need to do is set up a IIsWebFile with the proper configuration. I will first give the necessary steps in sequence, then explain what is happening with each step, and finally how it all works together at runtime.
cscript %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/ROOT/DefaultDoc Document.foobar
Create a zero byte file at /Document.foobar
cscript %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs CREATE W3SVC/1/ROOT/Document.foobar IIsWebFile
cscript %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/ROOT/Document.foobar/AccessFlags 512
cscript %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/ROOT/Document.foobar/ScriptMaps "*,C:\perl\bin\perl.exe %SYSTEMDRIVE%\Inetpub\Scripts\Script.cgi,1"
Now, make a request to http://www.mysite.com/ and notice that script.cgi gets executed and its response sent back. Notice that:
In other words, it does exactly what you are asking for and nothing else, no security issues, and runs circles around .htaccess
Here is the step-by-step explanation of what each above step accomplishes:
Now, the trailing "1" in the configuration is important because it makes the mapping into a Script Engine based scriptmapping (so code execution will not need the Execute permission). If you set it to "0", then the prior AccessFlags setting needs to be 4 instead of 512.
Basically, what I am doing is setting an arbitrary URL resource as the Default Document and then using IIsWebFile to modify the execution behavior associated with exactly that URL resource and nothing else.
Finally, at Runtime, this is what happens: