Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password Protecting site.com

    I downloaded a file uploader to use on my website so I have my own personal file uploading service for my files so I dont have to worry about any being removed but I dont want it to be usable by the public which is why I would like to add a password to it.. I tried doing it with .htaccess and .htpasswd by using this:
    Code:
    AuthName "Restricted Area" 
    AuthType Basic 
    AuthUserFile /home/efhx/.htpasswd 
    AuthGroupFile /dev/null 
    <Files *.php>
    require valid-user
    </Files>
    <Files *.js>
    require valid-user
    </Files>
    for some reason, I can get it to work if it requires authentication for every single file/folder on the website but I cant get it to work with just php,js files.. so I'm looking for alternative ways. Is there anything I can do to make site.com password protected but the public would be able to view all my other folders like site.com/images ?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    This doesn't have anything to do with PHP, moving to apache configurations.

    It doesn't look wrong, but I can't be 100% sure that the authtype works outside of the files block. Seems logical to me that it would. You can try this instead, and see how it works (I'm lazy, so I'll just use a filematch):
    Code:
    <FilesMatch "\.(php|js)$">
    AuthName "Restricted Area" 
    AuthType Basic 
    AuthUserFile /home/efhx/.htpasswd 
    Require valid-user
    </FilesMatch>
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Apr 2006
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    finally figured it out.. there was a blank space after htpasswd and some of the other lines.. got rid of them and it worked thanks for the help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •