Solved

htaccess - redirecting with a login.

Posted on 2004-08-16
6
170 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
[X]
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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
htaccess file 3 92
How to ensure a smooth transition to Let's Encrypt SSL Cert? 2 86
$_SERVER Variable question 31 52
Rewrite Rule head scratcher 18 29
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
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…

756 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