Search code examples
protected.htpasswd

How to make a protected file list on my server?


I've a silly question. I did not create a protected list of folder and file on my server with htaccess.

I've a folder protect with htpasswd. There is this in my htaccess :

AuthType Basic
AuthName "My Protected Area"
AuthUserFile .htpasswd
Require valid-user

But when i add this line for list the folder, i've an 500 error :

Options +Indexes

i've you got an idea of the problem ?

Sorry for my bad english !


Solution

  • You must specify an absolute path for the .htpasswd file. Try using an absolute path from the / folder from your machine.

    Example:

    AuthType Basic
    AuthName "My Protected Area"
    AuthUserFile /var/yourpath/.htpasswd
    Require valid-user
    

    TIP: I created a Gist on Github to help developers creating a basic .htaccess file. You can find it here.