2011-11-11 50 views
2

启用DirectorySlash如果我在网站的根在我的.htaccess验证码:而不显示查询

RewriteCond %{REQUEST_URI} ^/foo/bar/ 
RewriteRule ^foo/bar(.*)$ http://example.org/foo/?file=$1 [P,QSA] 

而且有这样的文件结构:

foo 
+-- index.php 
+-- bar 
     +-- qaz 
      +-- file.txt 

我请求的页面http://example.org/foo/bar/qaz/它将在服务器上重定向到http://example.org/foo/?file=/qaz/。 但是,如果我请求页面http://example.org/foo/bar/qaz它将重定向到http://example.org/foo/?file=/qaz,但它会在浏览器中显示http://example.org/foo/bar/qaz/?file=/qaz

如何启用DirectorySlash,但仍隐藏用户的查询?

回答

0

只有目录'/ foo/bar/qaz'存在时,DirectorySlash才会执行此操作。

DirectorySlash不尊重rewriteBase。你可以禁用它并自己做这个:

RewriteCond %{DOCUMENT_ROOT}/$1 -d 
RewriteRule ^(.*[^/])$ $1/ [R,L]