RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !public/
RewriteCond %{REQUEST_FILENAME} !.git/
#In some cases (web servers) It's need to set this parameter (RewriteBase), and if its in a folder, write it's name after forward-slash and also put a final forward-slash after it, too.
#RewriteBase /
#This parameter is used to set the default directory and it's file.
DirectoryIndex public/index.php
RewriteRule ^(.+)$ public/index.php/?q=$1
# To disallow folders to show their contents (files)
Options All -Indexes