Prevent users from accessing to specific folders and files in PHP

htacc

php_flag display_errors on
php_value error_reporting 9999

RewriteEngine On
RewriteBase /mvc1/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

Easiest solution would be to move index.php (and possibly assets) into the public folder and pointing the web server to that directory. That way users accessing the site from the web browser can only browse through the files that are inside the public dir, and not all your other files.

Sponsor our Newsletter | Privacy Policy | Terms of Service