htAccess重定向除assets文件夹之外的所有.php


htAccess redirect all .php except assets folder

我想用htaccess将所有.php脚本重定向到index.php。除了/assets/文件夹中的脚本。

例如:

   /test.php                         ->    /index.php
   /folder/test.php                  ->    /index.php
   /assets/test.php                  ->    /assets/test.php
   /assets/folder/folder/test.php    ->    /assets/folder/folder/test.php

这是我当前的htaccess文件:

RewriteEngine on
RewriteCond %{REQUEST_URI} !('.png|'.jpg|'.gif|'.jpeg|'.bmp|'.css|'.js|'.woff|'.woff2|'.map|'.ico|'.map)$
RewriteCond $1 !^(index'.php|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

找到了答案。。。

将此添加到.htaccess:

重写结束%{REQUEST_URI}^(/assets)