我正在尝试对所有请求进行重写,除非 URL 指向:
所以我有以下应该处理它:
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ redirect.php [QSA]
但是当我导航到包含
index.php
的文件夹时(是的,我已经检查过 DirectoryIndex
设置为 index.php
),它仍然执行重写。我还发现有趣的是,如果我有一个
.htaccess
在该文件夹中使用 RewriteEngine on
(仅此而已),那么上面的重写规则有效......任何指针?
最佳答案
在您的根 .htaccess 中尝试此规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1/index.php !-f
RewriteRule ^(.*?)/?$ redirect.php [L]
关于regex - RewriteCond 检查目录是否存在索引文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19663940/