尽pipe有重写规则,Apache还是会添加尾随斜线

我正在使用一个简单的.htaccess来处理一切与PHP脚本:

RewriteEngine on RewriteRule . index.php 

我的index.php只是回应服务器variables(使用print_r($_SERVER) ); 一切工作正常,我在URL中input任何东西,并显示index.php内容。 但是,考虑到这种结构:

 test/ # document root folder/ # empty folder index.php .htaccess 

我注意到访问[site]/folder首先将浏览器redirect到[site]/folder/ ,然后显示正确的index.php内容。 为什么发生这种情况? 是不是重写规则应该redirect一切“原样”?

这与虚拟主机一起使用,以在本地testing网站。 configuration与最低限度。 在我的.htaccess之前是否可以加载其他的apache文件?

 <VirtualHost *:80> ServerName test.local DocumentRoot /Library/WebServer/Documents/test/ </VirtualHost> 

目前使用OS X 10.10。

正如在上面的评论中所确定的那样, DirectorySlash指令控制着这个特定的Apache行为,而重写过程并没有导致它。 该指令默认为on 。 如果将其设置为off ,则当映射到文件系统上的目录的URI被请求而没有结尾斜杠时,Apache将不会将请求redirect到具有尾部斜杠的请求。

更多的信息在这里的文档: https : //httpd.apache.org/docs/current/mod/mod_dir.html#directoryslash