Solved

htaccess - redirecting with a login.

Posted on 2004-08-16
6
168 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
ID: 11816260
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
ID: 11819990
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
ID: 11828078
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
ID: 11830166
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
ID: 11830785
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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). #…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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