Htaccess group limited redirects?


#1

Hi all,

I’m setting up some password protected directories on my website, and I was wondering if it’s possible to use .htaccess to actually redirect to a specific html page in that directory depending on what group the user is part of.

I’ve currently got the login script sending users to a directory display where items are hidden or seen depending on the group using something similar to:

require group a

But it’d be nice to actually send them to a specific html page that loads.

Maybe with some permutation of AuthFormLoginSuccessLocation? I haven’t found decent information on doing something like this, so here I am!

Thanks!
–Brian


#2

If I understand correctly you want lets say 3 directories with different content which is protected by user/pwd and different for each directory.

If that is the case you can use a simple .htaccess file with an .htpasswd file in each dir.

Create the .htaccess with notepad or simular and put this in there,
where memberdir1 is a directory you want to protect (or whatever you want to call it):

AuthType Basic
AuthUserFile /home/your-DreamHost-username/yourdomain.com/memberdir1/.htpasswd
AuthName "Members Area of bla blabla"
require valid-user

Save it and be sure it has NO .txt behind it. The file MUST be called .htaccess (incl. the . dot)

The .htpasswd file is the file that has the username and passwords in there.
This you should create with a piece of software like “AutoSitePasswords” Google it
You can also create user/pwd with such a program and save it encrypted MD5

You upload both files to the folder you want to protect and now the content can only be accessed by people who have an user/pwd.

Repeat it all for any other directory you wish to protect.

Create on any page of your website a link to a page INSIDE the protected dir.
e.g. http://domain.com/memberdir1/content.html

Note: This only works on a basic HTML website. It will not work within a WordPress (or other php based) structure. If you want to use it with WordPress or other php then you MUST have the protected dirs outside the php structure/dir.