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

编程入门 行业动态 更新时间:2024-10-28 20:22:48
本文介绍了密码使用.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保护单个文件

本文发布于:2023-10-31 16:53:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546700.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码   文件   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!