htaccess 重写康德如何不在一个文件夹和其他文件中工作


htaccess RewriteCond how to not work in a folder and other files of that that

我的htaccess文件是。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} '.php$
RewriteRule ^(.*)$ first.php

现在我希望这个规则在我的管理文件夹中
不起作用就像我的管理员文件夹admin 所以当我的网址是

admin/logout.php然后不工作
RewriteCond %{REQUEST_FILENAME} '.php$

或者admin/ajax/ajax.php那么它是一样的直接命中 to ajax.php不重定向至 first.php

你的规则是这样的:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} '.php$
RewriteRule !^admin/ first.php [L,NC]

另一种简单的方法是使用以下语句将 .htaccess 文件放入您的管理文件夹中

   RewriteEngine Off

这将禁用管理文件夹中的所有重写。