.htaccess question

software development

#1

So I just want to protect one file … the index file in one directory using .htaccess - I used the option but am getting the error “401 Authorization Required” when going to the page, or anywhere in the domain. It appears it is not recognizing the option. Below is my entire .htaccess file

AuthType Basic
AuthUserFile /home/crew0791/jimthebrand.com/projects/.htpasswd
AuthName “Password”
<FilesMatch “index.html”>
require valid-user

the url is http://www.jimthebrand.com/projects/


#2

It is working, if you enter the full url “http://www.jimthebrand.com/projects/index.html” you get the user/pass dialog.

I’m not a .htaccess guru and I have no idea if it will help but try adding “DirectoryIndex index.html” before the Auth lines in the .htaccess.


Web Hosting Reviews | Shonky’s Blog


#3

Maybe you could experiment with something like this:-

AuthName "My File"
AuthType Basic
AuthUserFile /.htpasswd
Allow From All

Deny From All


Norm


#4

Move all the Auth stuff into the container, like so:

<FilesMatch "index.html"> AuthType Basic AuthUserFile /home/crew0791/jimthebrand.com/projects/.htpasswd AuthName "Password" Require valid-user </FilesMatch> Also, the argument to FilesMatch is a regular expression, so you should probably escape that dot (“index.html”).


If you want useful replies, ask smart questions.