阻止我的域

时间:2017-12-12 08:10:58

标签: javascript php html css .htaccess

其实我有一个网站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 其余index.html,contact.html,sitemap,robot.txt应该可以公开访问 www.domain.com/images/abcd.jpg < / strong>可以公开访问,但 www.domain.com/images / 不应公开访问。

谁能告诉我怎么做?

1 个答案:

答案 0 :(得分:0)

您可以在服务器配置或.htaccess中使用此选项禁用目录列表:

Options -Indexes

详细信息:https://wiki.apache.org/httpd/DirectoryListings

要将用户重定向到您的主页,请使用重写规则或在HTTP 403/404错误页面中添加重定向。