Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

htaccess - redirecting with a login.

Posted on 2004-08-16
6
169 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

791 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