Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

While I understand that this is a minor issue, I have wondered whether it is possible to disable redirects on directory urls in Apache2.

Currently, when connectiong to http://localhost/cgi, apache2 would redirect to http://localhost/cgi/, since $WEBROOT/cgi is a directory:

$ curl --head http://localhost/cgi
HTTP/1.1 301 Moved Permanently
Date: Fri, 20 May 2011 05:01:31 GMT
Server: Apache/2.2.17 (Ubuntu)
Location: http://localhost/cgi/
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

The reason I ask is because of a flaky connection to my webserver, where it usually takes an arguably long time to connect. I'd like to avoid unnecessary requests if possible.

Is there a way to disable this behaviour, so when connecting to http://localhost/cgi Apache would not attempt to redirect?

share|improve this question
up vote 0 down vote accepted

You can turn it off with the DirectorySlash directive in your config.

share|improve this answer
Neat, although the security warning is kind of a party pooper (also I can't upvote due to lack of reputation) :( – hiobs May 20 '11 at 8:24

Your Answer


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.