.htaccess探秘(二)目录浏览与主页

  •   
  • 3681
  • Linux
  • 6
  • super_dodo
  • 2015/11/06

目录浏览与主页

1. 启用和禁用目录浏览


Options All -Indexes
IndexIgnore *
Options All +Indexes

这3种设置分别对应下面3个图:
281020210638510

281020281885987

281020343137292

2. 禁用浏览某些文件
281020571109723


IndexIgnore *.php *.txt~ Copy*

281020488766573

3. 自定义目录浏览页面的style

<IfModule mod_autoindex.c>
 IndexOptions FancyIndexing 
</ifModule>

# http://corz.org/public/images/demo/
# http://corz.org/server/resources/file_view.htaccess.txt?raw=true

4. 配置目录主页文件

DirectoryIndex index.html index.php index.htm

5. 配置错误页面

# custom error documents
ErrorDocument 401 /err/401.php
ErrorDocument 403 /err/403.php
ErrorDocument 404 /err/404.php
ErrorDocument 500 /err/500.php

htaccess探秘系列相关延伸阅读

.htaccess探秘(一)访问控制(Allow/Deny)

.htaccess探秘(二)目录浏览与主页

.htaccess探秘(三)URL重写与URL重定向

.htaccess探秘(四)htaccess正则表达式

宁可慢些,不要太急而错误;宁可笨些,不要太巧而败事。