https://example.com/public
https://example.com/public/faq.php
https://example.com
https://example.com/faq.php
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^$ public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/$1 [L]
This rule works very well but it doesn't redirect if someone access "https://example.com/public/" or "https://example.com/public/faq.php"
I have found a workaround for this. I have added below code to redirect if the public directory will be accessed directly.
RewriteCond %{THE_REQUEST} /public [NC]
RewriteRule .* / [L,R]