My original goal was to rewrite requests to http://server.com/node/XXXXX to http://server.com/node/index.cgi?XXXXX. node really is a physical directory containing index.cgi, located directly under the document root. That bit is fairly straightforward:
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteBase /node
RewriteCond %{REQUEST_FILENAME} !index.cgi
RewriteRule ^(.*)$ /node/index.cgi?$1 [L,QSA]
...in the .htaccess file under /real/path/to/web/stuff/node.
Note that this means requests of the form http://server.com/node/ supply an empty query string to index.cgi, which is what I want.
So now the tricky part: I want requests to http://server.com/node to redirect to http://server.com/node/ — which, as above, redirects to index.cgi with an empty QS. The trouble is, if I don't have any rules in my root dir, a request for http://server.com/node does indeed seem to go to http://server.com/node/ — but I find that the query string given to index.cgi is the full physical path corresponding to the request (/real/path/to/web/stuff/node)!
I've tried a rule in my root level .htaccess like:
RewriteCond %{REQUEST_URI} =/node
RewriteRule ^(.*)$ /node/ [L] # (also tried [L,R=302])
But that has no effect.
I realise that Apache does some trailing-slash appending under the hood, but I can't use DirectorySlash Off... and I wouldn't want to if I could, since I have a Drupal installation residing in the root (there are a bunch if similar rewriting rules in there, but I don't think they're interfering).
So is it possible to either create a rule for the root directory .htaccess that works, or a modify the /node/.htaccess to make it not matter? Even physically moving things around is not beyond reason.
This is on a host running Apache 1.3.41 on FreeBSD 7.3. I don't have the ability to change anything about the server config itself, only my .htaccess files (which means I can't even turn on rewrite logging!).