How to avoid Navigation of folders through URL man

2019-03-06 02:55发布

问题:

Please i need your help with my website (testing stage). I have a file system of this nature...

     www (root)  
  {

           school { //main project folder

                  images //images folder

                  uploads //user uploads folder 

                  JavaScripts //JS folder

                  CSS // css folder

                 includes //includes folder

             index.php

            contactus.php

            aboutus.php

            register.php

           } //main project folder
  } //www folder               

how can i prevent users from browsing through my folder system when they do somrthing like these:

 http://127.0.0.1/school/css
 http://127.0.0.1/school/images
 http://127.0.0.1/school/includes
 http://127.0.0.1/school/uploads
 http://127.0.0.1/school/javascripts

Thnaks for your help....

回答1:

See the following article on how to disable direct directory browsing

Specifically, search for Options Indexes in your .htaccess file. If one does not exist, add the following line to your .htaccess:

Options -Indexes

Directory browsing should not be available.

More methods are available at the article above.



回答2:

You could also put an empty php or html file called index.php or index.html in every folder. The users will be unable to browse those directories.



回答3:

Create an .htaccess file to the directory you don't want to be navigated via url input..

and inside the file, put this line:

Deny from all

that's all.. enjoy..

and for security purposes use this lines instead:

Options -Indexes