Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!).

share|improve this question

1 Answer 1

The Apache 1.3 documentation has an entry referring to the "trailing slash problem", maybe it may help you for that scenario.

Regarding your rules with the node IDs, the RewriteBase maybe your problem since "the local directory prefix is stripped .. and your rewriting rules act only on the remainder" as documented in the RewriteBase docs.

share|improve this answer
    
Removing the RewriteBase didn't have any effect. I still get the full local path as the URL. –  detly Jan 25 '11 at 12:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.