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

htaccess route all except one file

我需要将任何 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]