.htaccess - 密码使用.htaccess保护单个文件

标签 .htaccess passwords cpanel .htpasswd

我尝试使用.htaccess密码保护单个文件。但是访问文件时,浏览器只是重定向到网站的主页。我的根目录上有.htpasswd。我的.htaccess文件如下

    <FilesMatch "result.php">
    AuthName "Member Only"
    AuthType Basic
    AuthUserFile /home/username/.htpasswd
    require valid-user
    </FilesMatch>

我想保护文件result.php。我用我的确切cpanel用户名替换了用户名。有人请帮忙

最佳答案

 <FilesMatch "results.php">
 AuthName "Member Only"
 AuthType Basic
 AuthUserFile /home/username/public_html/.htpasswd
 require valid-user
 </FilesMatch>
  • 必须放置密码目录
  • 的完整绝对路径

    关于.htaccess - 密码使用.htaccess保护单个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13570898/

    相关文章:

    wordpress - 混合内容/不安全内容 SSL

    php - 覆盖 PHP 配置选项

    authentication - 如何在 Sourcetree 中与 Github 建立基本连接

    java - 如何检查上传的文件是否受密码保护?

    mysql - 将Wordpress数据库迁移到服务器SQL错误

    regex - RedirectMatch 和 Regex 愚蠢行为

    apache - 将 www 重定向到非 www,同时保持协议(protocol) HTTP 或 HTTPS

    linux - 改进我的密码生成脚本

    cron - cPanel cron 作业,未指定输入文件?

    php - PhalconPHP 数据库事务在服务器上失败