开发者

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]


Options -Indexes

This will turn off directory listings.


In Terminal or SSH

chmod 750 <folderName>

Blocks the folder from Loading in browser ie blocking public access


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

deny from all

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜