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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-16-2006, 06:42 AM
|
#1
|
Member
Registered: Jul 2005
Location: California
Distribution: Slackware 11.0, Fedora Core 5
Posts: 80
Rep:
|
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!
|
|
|
03-16-2006, 07:27 AM
|
#2
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141
Rep:
|
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
|
|
|
03-16-2006, 07:32 AM
|
#3
|
Member
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
|
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.
|
|
|
03-16-2006, 05:03 PM
|
#4
|
Member
Registered: Jul 2005
Location: California
Distribution: Slackware 11.0, Fedora Core 5
Posts: 80
Original Poster
Rep:
|
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!
|
|
|
03-17-2006, 03:42 AM
|
#5
|
Member
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
|
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>
|
|
|
All times are GMT -5. The time now is 06:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|