密码使用.htaccess保护单个文件 [英] password protect a single file using .htaccess

查看:99
本文介绍了密码使用.htaccess保护单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have tried to password protect a single file using .htaccess. But when accessing the file the browser just redirects to the home page of the website. I have my .htpasswd on my webroot. My .htaccess file is given below

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

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

I want to protect the file result.php. I have replaced username with my exact cpanel username. Someone please help

推荐答案

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




  • 必须放置密码目录的完整绝对路径

  • 这篇关于密码使用.htaccess保护单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆