views:

735

answers:

2

I'm creating a small application on an embedded device that has a boa web server running on it. I'm creating a web application in a mixture of plain HTML pages and Perl scripts to interface with the main application. Is there a way to hide the fact that some of the pages are being served out of the cgi-bin on the device?

What I have now are the following URLs.

What I would greatly prefer would be:

with the above URLs taking me to the appropriate index.html or index.pl document. Is there some combination of file structure and server settings that will enable this behavior?

I've searched Google for this, but as you can imagine I'm getting pages and pages of search results with "cgi-bin" in the URL. I'm hoping someone here has done this before.

EDIT: I should mention that I know how to do this for plain HTML pages by making separate folders in my web root, all with index.html pages. My problem is in getting this type of solution to work with .pl or .cgi files in the cgi-bin directory.

+7  A: 

In apache, this would be simple with mod_rewrite, but boa is a little different. You've got a couple of different issues going on here. For the .html files make sure you have the following line in boa.conf:

DirectoryIndex /index.html

Then any file that is called index.html will be retrieved when hitting the root. So if your root directory is /htdocs then makings /htdocs/index.html and /htdocs/info/index.html should take care of those problems.

For your other scripts, you'll need to add the following line:

AddType application/x-httpd-cgi pl

That should let perl execute as CGIs execute everywhere. Then it's a matter of making sure that boa knows they're the index files. You may be able to get over some of that using Redirect or Alias directives.

Pridkett
I should have written in my question that I know how to do this for the html files, sorry. The rest of your answer was helpful, though. I still need to clue boa in that .pl or .cgi files can be index files. It only seems to accept one index file name. :(
Bill the Lizard
+7  A: 

Boa unfortunately doesn't appear to have any type of mod_rewrite options available to it, so you're limited in what you can do to rewrite a URL. From the boa docs here are the options you do have available:

Redirect, Alias, and ScriptAlias

Redirect, Alias, and ScriptAlias all have the same semantics -- they match the beginning of a request and take appropriate action. Use Redirect for other servers, Alias for the same server, and ScriptAlias to enable directories for script execution.

Redirect

allows you to tell clients about documents which used to exist in your server's namespace, but do not anymore. This allows you tell the clients where to look for the relocated document.

Alias

aliases one path to another. Of course, symbolic links in the file system work fine too.

ScriptAlias

maps a virtual path to a directory for serving scripts.

Based on that you might try ScriptAlias or Alias, or even a symlink to a "nicer" URL. Unfortunately since I don't have Boa available here I can't test the options to tell you more specifically what to try.

Jay