.htaccess不能在localhost上运行,但在实时服务器上运行(htaccess覆盖打开)

this exact .htaccess works on live server, but not on localhost (shows page with web structure), why?

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ /public/index.php [L]

This .htaccess works on both:

RewriteEngine On
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]

I'm doing something wrong, but don't know what, please help me.

Is there a folder /public on localhost? It seems like this folder only exists on the live-system. Or eventually the DocumentRoot is different.

Anyway, the only difference I see:

/public/index.php

which is an absolute path from DocumentRoot. --> /path/to/DocumentRoot/public/index.php

index.php

which should be a relative path from from DocumentRoot. --> /path/to/DocumentRoot/index.php

Make sure you are rewriting to the correct location.