Vicky
Vicky

Reputation: 9585

protect my public folder from direct access using htaccess rules

Hi I am new to PHP. I am using codeignitor, just want to protect my public folder from direct access. e.g. Refer below url. when i enter this URL in browser on my local machine it shows all my static files.

http://localhost/myapp/public/

This is htaccess file content. So could you please help how i protect my public folder from direct access.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Upvotes: 1

Views: 1837

Answers (3)

Christophe Eblé
Christophe Eblé

Reputation: 8161

In the directory, create a plain text file that you name .htaccess and put this line in it:

deny from all

Upvotes: 0

Kyle
Kyle

Reputation: 22258

Options -Indexes

This will turn off directory listings.

Upvotes: 2

Sathish Manohar
Sathish Manohar

Reputation: 6119

In Terminal or SSH

chmod 750 <folderName>

Blocks the folder from Loading in browser ie blocking public access

Upvotes: 0

Related Questions