Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove "cgi-bin" from my URLs?

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.

  • http://localhost/home.html
  • http://localhost/cgi-bin/config.pl
  • http://localhost/cgi-bin/control.pl
  • http://localhost/info.html

What I would greatly prefer would be:

  • http://localhost/
  • http://localhost/config/
  • http://localhost/control/
  • http://localhost/info/

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.

like image 311
Bill the Lizard Avatar asked Jan 21 '09 18:01

Bill the Lizard


People also ask

How do I get rid of CGI-bin?

Can you delete cgi-bin? The cgi-bin is located in the directory root of your website. If there are no scripts stored in that folder, you can delete that folder. It should not be a problem with your website.

Where is CGI-bin located?

If you look in the /var/www (the document root of Apache), you will find a sub-directory called cgi-bin. This is not where your Perl programs and other various files will be placed. Within the /usr/lib/ directory, you will find another cgi-bin directory; it is the repository for your executables.

What is CGI-bin folder for?

A CGI-bin is a folder used to house scripts that will interact with a Web browser to provide functionality for a Web page or website. Common Gateway Interface (CGI) is a resource for accommodating the use of scripts in Web design.


1 Answers

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.

like image 60
Jay Avatar answered Sep 23 '22 21:09

Jay