htaccess 的使用基本小节 For apache httpd

Apache 手册

htaccess 的使用基本小节 For apache httpd

  1. .htaccess的基本作用

           .htaccess是一个纯文本文件,它里面存放着Apache服务器配置相关的指令。
           .htaccess主要的作用有:URL重写、自定义错误页面、MIME类型配置以及访问权限控制等。主要体现在伪静态的应用、图片防盗链、自定义404错误页面、阻止/允许特定IP/IP段、目录浏览与主页、禁止访问指定文件类型、文件密码保护等。
           .htaccess的用途范围主要针对当前目录。

  2. 启用.htaccess的配置
    httpd.conf:
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    改为:
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    </Directory>
    

      

  3. .htaccess  白名单配置
    使用命令创建 .htpasswd 文件 
      htpasswd -c .htpasswd 用户名
    更新 .htpasswd 文件
      htpasswd .htpasswd 用户名
    AuthUserFile /Users/jerryxu/wwwroot/cache/server/backup/1115just4/.htpasswd
    AuthName "Restricted Access"
    AuthType Basic
    require user 用户名
    ###### deny from ip
    

      require user 用户名 = require valid-user [用户名]

      

  4. 更多可参考;blog.csdn.net/cmzhuang/article/details/53537591
posted @ 2019-04-24 18:55  徐锅  阅读(223)  评论(0编辑  收藏  举报