Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

htaccess - redirecting with a login.

Posted on 2004-08-16
6
Medium Priority
?
174 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 400 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month11 days, left to enroll

886 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