禁止 web页面访问 .git 文件夹

2016年11月17日

Nginx

  1. location ^~ /.git {
  2. return 404;
  3. }

Apache 2.2

  1. <Directory "/home/data/www/htdocs/made/.git">
  2. Order Deny,Allow
  3. Deny from all
  4. </Directory>

Apache2.4

  1. <Directory "/var/www/html">
  2. #
  3. # Possible values for the Options directive are "None", "All",
  4. # or any combination of:
  5. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  6. #
  7. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  8. # doesn't give it to you.
  9. #
  10. # The Options directive is both complicated and important. Please see
  11. # http://httpd.apache.org/docs/2.4/mod/core.html#options
  12. # for more information.
  13. #
  14. Options FollowSymLinks
  15. #Options Indexes FollowSymLinks
  16. #
  17. # AllowOverride controls what directives may be placed in .htaccess files.
  18. # It can be "All", "None", or any combination of the keywords:
  19. # AllowOverride FileInfo AuthConfig Limit
  20. #
  21. AllowOverride All
  22. Order deny,allow
  23. Allow from all
  24. #
  25. # Controls who can get stuff from this server.
  26. #
  27. Require all granted
  28. </Directory>

没有评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注