Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

password protect a single file using .htaccess

Tags:

People also ask

How do I password protect just one file?

Use encryption to password protect a folder or a file Navigate to the folder or file you want to encrypt. Right-click on the item, click Properties, then click Advanced. Check Encrypt contents to secure data. Click OK, then click Apply.


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>

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