php spl_autoload无法从其他目录运行

this is my index.php file in project root:

spl_autoload_extensions('.php');
spl_autoload_register();

I added this into htaccess in order to redirect everything into public folder:

RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

Inside public folder I just included index file like so:

// public/index.php file
require '../index.php';

But it's throwing an error:

Fatal error: spl_autoload(): Class controllers\TestController could not be loaded

Why? If I remove htaccess and not use public folder it works perfectly.