使用 .htaccess 密码保护单个文件 [英] password protect a single file using .htaccess
本文介绍了使用 .htaccess 密码保护单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用 .htaccess 对单个文件进行密码保护.但是在访问文件时,浏览器只会重定向到网站的主页.我的 .htpasswd 在我的 webroot 上.我的 .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屋!
查看全文