【发布时间】:2018-05-25 20:40:05
【问题描述】:
其实我有一个网站 www.domain.com
当我试图检查元素并尝试访问 www.domain.com/css/ 然后它显示了目录中的所有文件
结构
- /css/
- /图片/
- /包括/
- /js/
- index.html
- contact.html
- sitemap.xml
- style.css
- robot.txt
- .htaccess
我想保护 css,images,include,js 文件夹意味着如果有人尝试访问 www.domain.com/images/,那么他应该被重定向到 www.domain。 com/index.html rest index.html,contact.html,sitemap,robot.txt 应该可以公开访问,www.domain.com/images/abcd.jpg 可以公开访问但 www.domain.com/images/ 不应公开访问。
谁能告诉我该怎么做?
【问题讨论】:
-
在所有文件夹中放置一个空白的
index.html文件。如果您想通过 htaccess 执行此操作,请输入Options -Indexes。 -
使用 htaccess 重定向到 index.html
-
最好用403禁止处理,而不是
标签: javascript php html css .htaccess