Password protect download directly in wordpress

I’m trying to password protect a directory in wordpress in my cpanel and it’s not working, wordpress keeps picking up the URLs and writing to it’s own software. How can I get around this?

Even if I put my files in /wp-content/uploads/downloads/ it’s still not recognizing them as downloadable, it forwards to a wordpress 404 error

Related posts

Leave a Reply

2 comments

  1. 1) create a .htaccess file in the directory you want to hide with this content:

     AuthUserFile /www/path/to/file/.htpasswd
     AuthGroupFile /dev/null
     AuthName "Confidential Information"
     AuthType Basic
     require user admin
    

    then create a .htpasswd file with this content:

    admin:password
    

    and then only user ‘admin’ with password ‘password’ should be able to access directory.

    or..

    2) if you just move it below than the public HTML root folder then you don’t have to worry about password protecting it – nobody can access it without direct server access

  2. Create a .htaccess file in your downloads directory:

    AuthUserFile /path/to/file/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Confidential Information"
    AuthType Basic
    require valid-user
    

    Create a htpasswd file (outside your web root) like so:

    htpasswd -bc /path/to/file/.htpasswd admin password