0

I've got a file accessible through my web website by typing http://www.mywebsite.com/myfile and the server run on debian.

I'd like to put an authentication with a .htaccess and .htpasswd when trying to access to previous url.

I'm quite new to .htaccess and I tried to configure it with the doc but it doesn't seems to work since when i try nothing change and when i check the error log I've got :

[error] [client IP] client denied by server configuration: /home/file1/myfile/www/.htaccess

The content of my .htaccess is :

<Directory /home/file1/myfile/www/>
    AuthUserFile /home/file1/myfile/.htpasswd
    AuthGroupFile /dev/null
    AuthName "My authentication"
    AuthType Basic
    Require valid-user

    Otions Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order allow,deny
    allow from all

    Redirect permanent /.htaccess http://www.mywebsite.com/myfile
    ServerSignature Off
</Directory>

How may I solve this problem please ?

bash_profile blank
  • 311
  • 1
  • 4
  • 13

2 Answers2

0

You can't use a <Directory> container in an htaccess file. Remove them so you just have:

AuthUserFile /home/file1/myfile/.htpasswd
AuthGroupFile /dev/null
AuthName "My authentication"
AuthType Basic
Require valid-user

Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order deny,allow
deny from all

Redirect permanent /.htaccess http://www.mywebsite.com/myfile
ServerSignature Off

(you have Otions mispelled)

Also, by looking at your error, it looks as if you were trying to access the htaccess file directly, instead of myfile. It's possible there's extra configuration on the server to deny accessing htaccess files (or all files that start with a .).

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Actually I do want deny the access to the htaccess. For the moment when I try to access directly to the htaccess, I've got a 403 error but I would like to redirect the user instead. Unfortunately it stills doesn't work :( – bash_profile blank Aug 08 '13 at 08:16
  • @bash_profileblank if there is some server configured 403 for htaccess files (for anything that starts with a `.`), the redirect *will never get applied*. – Jon Lin Aug 08 '13 at 08:20
  • Ok, so i cannot redirect it. But how come i've got no authentication asked when i access to the url ? – bash_profile blank Aug 08 '13 at 08:58
  • @bash_profileblank just realized that you have `allow from all`, which needs to be `deny from all`. – Jon Lin Aug 08 '13 at 09:01
  • I cannot connect in FTP since i removed the container, how do i correct that ? – bash_profile blank Aug 08 '13 at 14:44
0

It seems that deleting et creating again the user is enough to fix the FTP connexion problem.

I've modified my global apache configuration with the following :

DirectoryIndex index.html index.htm index.xhtml index.php index.txt

ServerName debian.domain.tld
#ServerName localhost
HostnameLookups Off

ServerAdmin myadressemail

UserDir www
UserDir disable root

<Directory />
    Options -Indexes FollowSymLinks
    AllowOverride All
</Directory>

ServerSignature Off

An now my .htaccess is :

AuthUserFile /home/file1/myfile/.htpasswd
AuthGroupFile /dev/null
AuthName "My authentification"
AuthType Basic
Require user user1

But I still have got no authentication asked, what did I do wrong ?

bash_profile blank
  • 311
  • 1
  • 4
  • 13