How to avoid Navigation of folders through URL man

2019-03-06 02:31发布

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....

3条回答
叛逆
2楼-- · 2019-03-06 03:05

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
查看更多
倾城 Initia
3楼-- · 2019-03-06 03:17

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.

查看更多
手持菜刀,她持情操
4楼-- · 2019-03-06 03:25

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.

查看更多
登录 后发表回答