Navigate
Sponsors
|
SSI User Redirection on LoginIntroductionThe following is required: when a user logs into a directory protected with .htaccess the user needs to be redirected to a particular page based on who the logged-in user is. One very easy way to do this is by using Conditional or Extensible SSI (don't ask me what the difference is!) which also allows us to build custom dynamic pages to suit. Step 1 - Entry PointSelect your point of entry for the protected directory i.e. the page the user goes to after logging in. This page will contain the redirect codes, name it something simple like index.shtml or redirect.shtml. Don't forget the .shtml extension if you want the file to be parsed by the server. For the purposes of this guide i'm taking it that we are using SSI on ALL pages and therefore all have the extension .shtml! There is a very handy script available which allows you to access .htaccess protected directories via a login form instead of the usual boring pop-up alert thingy! You can get it from a number of sites including - http://javascript.internet.com. Just search there for the "HTACCESS LOGIN" Script. Step 2 - RedirectingWhat we are going to do is simply check who the user is and include code to match.
If that makes sense? Example 1::
<!--#if expr="$REMOTE_USER = 'user1'" --> What this is basically saying is: Rather than redirect to another page you could choose to display user specific content or a link to a specific page, for example:
<!--#if expr="$REMOTE_USER = 'user1'" --> This gives the user a direct link to their specific page. The above snippet of code would result in: Welcome user1, you will now be redirected
to your personal page. Example 2:: The same effect as above can basically be accomplished with a single line of code: <META HTTP-EQUIV="Refresh" CONTENT="1; URL=<!--#echo var="REMOTE_USER" -->.shtml"> or with a javascript version:
<script language="JavaScript"> The limitations with Example 3 is that ya gotta make sure to name the users
page or directory the same as their login name which
you don't need to do for the first example above!! So user1 must be redirected to
user1.shtml or user1/, user johnthomas must be redirected to johnthomas.shtml or johnthomas/ etc |