在我的WebServer上,我有一个htaccess文件,如下所示:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
因此,对我的WebServer的所有调用都被重定向到我的根目录中的index.php文件,其中包含一个保存所请求文件的path参数。现在看看这两个电话:
domain.com/test/blub.php works -> path = test/blub.php
domain.com/test/ does not work -> path should be test
如何实现第二次通话也有效?
答案 0 :(得分:2)
从您的规则中删除此条件:
DirectorySlash Off
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/?$ /index.php?path=$1 [NC,L,QSA]
因为这是从此规则中跳过所有真实目录。
将您的规则用作:
{{1}}