LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-16-2006, 05:42 AM   #1
mustangfanatic01
Member
 
Registered: Jul 2005
Location: California
Distribution: Slackware 11.0, Fedora Core 5
Posts: 80

Rep: Reputation: 15
Apache .htaccess question


Hi everyone, I'm trying to use the .htaccess file to create custom 404 error page and login to password-protected directories. When I place this file and the corresponding .htpasswd in my server's root directory it works just fine. However I have allowed users public_html directories, and for some reason the .htaccess will not work for those users. For example if you type http://mysite.com it will prompt for user/pass. However if you type http://mysite.com/~eric it will ignore the fact that there is an .htaccess file there and just let you in. It also does not do the custom 404 error page specified there. So for reason the .htaccess file isn't even being read i guess. I have directory listing enabled for this user, but I don't see how this could affect it. Any ideas why this could be happening? Thanks!
 
Old 03-16-2006, 06:27 AM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have you had a look at the Apache web site and the info they provide on .htaccess files at http://httpd.apache.org/docs/2.0/howto/htaccess.html? They recommend putting authentication directives in a <Directory> section, in your main server configuration file, as the preferred way to implement authentication.

However, they do also note that to do this in .htaccess files, you will need "AllowOverride AuthConfig" in effect for the directive to be honored. Do you have the following in your .htaccess file (modified for your setup of course)?
Code:
AuthType Basic
AuthName "Password Required"
AuthUserFile /www/passwords/password.file
AuthGroupFile /www/passwords/group.file
Require Group admins
 
Old 03-16-2006, 06:32 AM   #3
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
Quote:
Originally Posted by mustangfanatic01
When I place this file and the corresponding .htpasswd in my server's root directory it works just fine. However I have allowed users public_html directories, and for some reason the .htaccess will not work for those users.
I'm not sure i'm getting you so just to remove any misunderstanding... Are you expecting this to work only with the .htaccess you placed in your apache root directory ? This will be the case only if the particular public_html is a filesystem descendant of your apache root directory (i.e. apache root dir is /bla/www and the other is /bla/www/somemorepaht/public_html with the .htaccess file being placed in /bla/www). Since I guess it is not the case, you need an other .htaccess file in each public_html dir you want to customize. If this was not the case, then try it and ignore the following.


Quote:
Originally Posted by mustangfanatic01
For example if you type http://mysite.com it will prompt for user/pass. However if you type http://mysite.com/~eric it will ignore the fact that there is an .htaccess file there and just let you in. It also does not do the custom 404 error page specified there. So for reason the .htaccess file isn't even being read i guess. I have directory listing enabled for this user, but I don't see how this could affect it. Any ideas why this could be happening? Thanks!
In your httpd.conf, you should have some directives for user dirs (<Directory /home/*/public_html> or such...). Double check the values for the "AllowOverride" directive. For authentification and error documents to work, you need at least "AllowOverride AuthConfig FileInfo" in there.
 
Old 03-16-2006, 04:03 PM   #4
mustangfanatic01
Member
 
Registered: Jul 2005
Location: California
Distribution: Slackware 11.0, Fedora Core 5
Posts: 80

Original Poster
Rep: Reputation: 15
Thanks guys! at the end of my httpd.conf I need to add the following:

<Directory "/home/ermcgrat/public_html">
Options +Indexes
IndexOptions FancyIndexing IconsAreLinks
AllowOverride AuthConfig
</Directory>

This enabled directory listing and the ability for .htaccess to work!
 
Old 03-17-2006, 02:42 AM   #5
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
As stated before, this will only work for authentification, not for error documents. Moreover, it will work only for one particular userdir. If you want to enable authentification and error documents overrides for all userdirs you need:
Code:
<Directory "/home/*/public_html">
    AllowOverride AuthConfig FileInfo
    .... some other directives .....
</Directory>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache and .htaccess jamluv Linux - Security 9 06-03-2005 02:53 PM
Apache/2.0.51 .htaccess 2782d4 Linux - Software 2 02-08-2005 12:12 PM
apache .htaccess emetib Linux - Software 4 09-22-2003 06:50 AM
is htaccess on apache 2.0 not the same as in 1.3 abd_bela Linux - General 3 07-23-2003 05:17 AM
.htaccess in apache 2 im1crazyassmofo Linux - Software 1 04-04-2003 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration