Solved

htaccess - redirecting with a login.

Posted on 2004-08-16
6
166 Views
Last Modified: 2010-03-04
I have two pages on my site - index1 and index2, and 2 users - userA and UserB.
How do I code the .htaccess file so that if userA logs in, they are directed to index1 etc.
Any suggestions.?
0
Comment
Question by:theaussie
  • 2
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
xDamox earned 100 total points
Comment Utility
Example (httpd.conf)

<Directory /home/www/htdocs/kimmel>
AuthType Basic
AuthName "By Invitation Only"
AuthUserFile /home/www/passwd/users
AuthGroupFile /dev/null
require user kimmel
</Directory>

[ see @ http://httpd.apache.org/docs/mod/core.html#authtype ]

then I used the utility .htappswd to create the password file

.htapsswd -c /home/www/passwd/users kimmel

[ see @ http://httpd.apache.org/docs/programs/htpasswd.html ]
0
 

Author Comment

by:theaussie
Comment Utility
I don't have access to httpd.conf. How do I do it using only htaccess and htpassword.?
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
use following directory hierachy:

<DocuemntRoot>/userA/index1
<DocuemntRoot>/userA/.htaccess
<DocuemntRoot>/userB/index2
<DocuemntRoot>/userB/.htaccess

in your .htaccess write:

  AuthType Basic
  AuthName "get it"
  AuthUserFile /path/to/htpasswd
  AuthGroupFile /dev/null
  require user userA

same for userB in its .htaccess
0
 

Author Comment

by:theaussie
Comment Utility
index1 and index2 are in the same directory. Can I do it with a single htaccess and a single htpasswd.?
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
never tested, but worth a try (sorry can't test myself at the moment):

<Files "index1">
  AuthType Basic
  AuthName "get it"
  AuthUserFile /path/to/htpasswd
  AuthGroupFile /dev/null
  require user userA
</Files>
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now