禁用目录redirect

虽然我知道这是一个小问题,但我想知道是否可以在Apache2中禁用目录URL上的redirect

目前,当连接到http://localhost/cgi ,apache2会redirect到http://localhost/cgi/ ,因为$WEBROOT/cgi是一个目录:

 $ 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 

我问的原因是因为我的networking服务器的连接,通常需要很长时间才能连接。 如果可能,我想避免不必要的请求。

有没有办法来禁用这种行为,所以当连接到http://localhost/cgi Apache不会尝试redirect?

您可以在configuration中使用DirectorySlash指令closures它。

http://httpd.apache.org/docs/2.0/mod/mod_dir.html