How to avoid Navigation of folders through URL manipulation

十年热恋 提交于 2019-12-20 07:09:01

问题


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


来源:https://stackoverflow.com/questions/10376113/how-to-avoid-navigation-of-folders-through-url-manipulation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!