.htaccess question


Mar 6, 2003
Okay I'm simply just trying to make it so the when you log on to www.mysite.com. The first page you see is your "index.htm" file. I want to password protect that page and then when you put the username and password in it redirects you to "home2.htm"

Here's the code I have for the .htaccess file

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /public_html/downloads/.htpasswd/.htpasswd
AuthGroupFile /dev/null
<Files home2.htm>
require valid-user

I put that file into the "public_html" folder

Then I uploaded the .htpasswd file into a different directory called "downloads" inside the "public_html" folder. which I used a username and password generator for which looked something like this


When I go to the site nothing happens, no pop up box at all. Am I doing something wrong? Any help would be much appreciated
Too bad you don't run your own server, you can control that directly from the apache config file. Maybe you should contact your host, if they allow it, then they would/should have no problem helping you.
Take a look at the Apache docs on Authentication.

This is completely dependant of how your host's apache is configured. If they allow you to override authentication from .htaccess then you should just need to make your .htaccess similar to this and place it in the directory you want to protect.

AuthType Basic
AuthName "Authorized users only"
AuthUserFile /home/SiDiuS/Documents/password.file
require valid-user

A big thing I would suggest would be to put your password file in a directory that is not accessible from the web. (outside of public_html)

If you want to put up a greeting page, then I would just move the contents of your site (& .htaccess) to a lower level directory and have a page that does a redirect (meta-refresh or just a hyperlink) on the root of your site.