Don't want to show my folder file structure from browser url

浪子不回头ぞ 提交于 2020-01-04 05:11:43

问题


I don't want to show my images, zip files or any other files. Because all of these very important files.

Suppose my image url like it

http://www.example.com/users/upload/images/example.jpg

And if anyone can take below url and go with browser url then they can see my all other images.

http://www.example.com/users/upload/images/

I don't want to show my images files, Or i want to show some 404 page not found.

Can anyone know the solution of above problem?


回答1:


You can create a .htaccess file for the folder(images), which should have denied access with

Deny from  all

or you can redirect to a custom 404 page

Redirect /images/ 404.html

For more information,

http://www.sitepoint.com/htaccess-for-all/



回答2:


Try this in your apache config file:

<Location />
  Options -Indexes
</Location>



回答3:


You can use .htaccess to do that. I guess Options -Indexes to your htaccess will do the trick.




回答4:


you can put a .htaccess file in that folder that contains just:

deny from all

That way you cannot open any file from that folder by url, but you can include them in php without any problems.




回答5:


In addition to adding Options -Indexes to your htaccess file, add a/an index.html or index.php inside any directories whose structure you are trying to protect. That way when the user navigates to them, rather than seeing the directory structure, they'll just get served the index file. The index file does not need to contain any code or text.



来源:https://stackoverflow.com/questions/29229811/dont-want-to-show-my-folder-file-structure-from-browser-url

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