in reply to Re: Perl file names and extensions
in thread Perl file names and extensions

davorg, thanks for this example. I have seen URL's like this, but could not figure out how it worked. However, I'm still not sure of the mechanics.

I assume that the index.cgi is in the directory "login" in your example, but does the lone "?" fire the cgi without the need of a program name, as in: /login/index.cgi?mode=new. I.e., the "index.cgi" is not needed, right?

This is the first time I've been exposed to mod_rewrite and have done some Super Searching and found this by Mad Hatter. Would something like this work with your example?

RewriteEngine on RewriteBase /subDir/ # only redirect if the file requested isn't index.cgi # capture anything else and redirect it to index.cgi RewriteCond %{REQUEST_FILENAME} !^index.cgi RewriteRule ^(.+)/?$ index.cgi?rm=$1 [L]

Well, I'll try this to see if it works differently or better than my usual .htaccess:

Options +ExecCGI SetHandler cgi-script

—Brad
"Don't ever take a fence down until you know the reason it was put up. " G. K. Chesterton

Replies are listed 'Best First'.
Re^3: Perl file names and extensions
by BUU (Prior) on Aug 03, 2004 at 23:17 UTC
    You are over thinking it. url.tld/foo/bar/, in apache, attempts to open whatever the default page for a folder is. In most installs of apache, url.tld/foo/bar/ resolves to url.tld/foo/bar/index.html However, you can change which file extensions you want the index page to use, for example, change it to .pl or .cgi. Then url.tld/foo/bar/ resolves to url.tld/foo/bar/index.pl and anything after the question mark is passed to that cgi. You'll notice perlmonks does something similar. The default page is index.pl so perlmonks.org resolves to perlmonks.org/index.pl so perlmonks.org?foo=bar resolves to perlmonks.org/index.pl?foo=bar

      Thanks BUU, got it. Tried out with "index.cgi" and worked like a champ. Though it really gets complicated if I'm passing lots of params, because I first have to call index.cgi and pass something that tells which script to run and then all the params related to that script. So, instead of:

      url.tld/foo/bar/login?name=robert&pass=sf67dfs

      I believe I need:

      url.tld/foo/bar/?run=login&name=robert&pass=sf67dfs

      which doesn't get me that much further. I think I'm ready to go back to cgi-bin ;^)


      —Brad
      "Don't ever take a fence down until you know the reason it was put up. " G. K. Chesterton