What is the best way to hide a websites folder/ directory files [duplicate]

*爱你&永不变心* 提交于 2019-12-03 07:55:12

问题


If I would visit my website by "www.mysite.com/img/"

I would see the following:

Parent directory...

folder1

folder2

file1

file2

etc etc..

But what is the best way to prevent people from visit my websites folders and file structure?

While still letting pople view eg the images on the actual website

I also want to hide eg www.mysite.com/functions/ where I have my php function-files.

Checking on google shows me alot of ways to do this,

but what is the best and safest way?

Thanks in advance!


回答1:


If your server is Apache you can setup an .htaccess file and build rules to hide/redirect and return a 404 Error page.

If your server is IIS then you can modify the "URL Rewrite" rules in your IIS Manager to return a 404 Error/Forbidden page.

See: .htaccess tips & tricks




回答2:


Create an index.html or index.php file inside, for example, the img folder; so when a visitor attempts to visit yourwebsite.com/img/ and see the content, index.html will be showed instead.



来源:https://stackoverflow.com/questions/19439348/what-is-the-best-way-to-hide-a-websites-folder-directory-files

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