Php htaccess路由除一个文件外的所有文件

Php htaccess路由除一个文件外的所有文件,php,regex,.htaccess,routing,slim,Php,Regex,.htaccess,Routing,Slim,我需要将所有url重定向到index.php,除了worker.php文件之外 目录: service/public/index.php service/public/.htaccess service/worker.php 我的.htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] 您可以添加一个额外的重写条件,即仅当请求的文件中没有worker.php时

我需要将所有url重定向到index.php,除了worker.php文件之外

目录:

service/public/index.php
service/public/.htaccess
service/worker.php
我的.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

您可以添加一个额外的重写条件,即仅当请求的文件中没有
worker.php
时,才应用
index.php
重写规则

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !worker\.php$
RewriteRule ^ index.php [QSA,L]

你的意思是说浏览器可以直接访问
worker.php
,但你希望它被重定向到index.php吗?不…如果url是:website.com/worker.php,那么它会转到这个文件,在任何其他情况下,它会转到index.phpWell,这是愚蠢的,因为你想将webroot设置为公共目录。。。否则,您的站点将位于domain.com/public/