1
我想将所有非文件,非目录重定向到index.php,因此存在的所有内容都可以直接访问 - 除了一个目录到的index.php)如何排除除一个目录以外的所有文件和目录,RewriteCond
我所拥有的是:
# Files
RewriteCond %{REQUEST_FILENAME} !-f
# Directories except /orderfiles/*
RewriteCond %{REQUEST_FILENAME} ^/(orderfiles/)* [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
这适用于目录内/ orderfiles,但文件内/ orderfiles还是到该文件。我尝试添加
RewriteCond %{REQUEST_FILENAME} ^/(orderfiles/)* [OR]
RewriteCond %{REQUEST_FILENAME} !-f
但这种休息和每一个文件发送到index.php文件。
感谢快速反应 - 我意识到我打错了我想要做的事情,我的意思是“但发送一个目录到index.php”(我编辑我的问题更加准确)。我希望/ orderfiles被路由到index.php。 –
谢谢!我仍然遇到麻烦(没有像你发布的括号一样,它不会工作),所以我改变了^(/ orderfiles /)*到^/new/orderfiles /,我有RewriteBase/new/above,所以我没有意识到我不得不包含/新/再次。这使所有的工作。再次感谢。 –