如何保护public_html中的文件夹免受访问者的侵害

I need to keep all my files and folders of my website in public_html folder. There are some folders for javascript codes like 'Javascript' and css codes like 'CSS', 'Images' for images, etc. It is easy for any visitor to type just the folder address like 'http://www.website.com/Javascript' and he will have permission to see all my javascript codes. I want to restrict these folders from visitors and use only for my scripts which are uploaded in public_html folder. How can this be done? Please give solution for my scripts in public_html also, which will need to access those folders.

For your security purpose you can set access permission for the public access for particular files, folder etc with the apache .htaccess file.

In your case create .htaccess file in the folder name public_html and put the bellow htaccess configuration:

Completely restricted from web server.

Deny from all

Restrict folder, sever can access files.

Options -Indexes

This works for me.