Access by HTML user

Gerald Combs gerald at ethereal.com
Fri Oct 31 20:08:23 CST 2003


On Fri, 31 Oct 2003, Jonathan Hutchins wrote:

> Is there a way to hide or display items on a web page according to which user 
> is logged in using HTML logins?

HTML-authenticated usernames are stored in the REMOTE_USER environment
variable.  If your web page is dynamically generated, you can check the
value of this variable within the script that generates the web page
content, and act accordingly, e.g.

# Inside a perl script
if $ENV{REMOTE_USER} eq "jonathan" {
  print "Jonathan's secret content"
} else {
  print "Nothing to see here."
}

If your web page is statically generated, you can use Apache's rewriting
engine to deliver different web pages to different users:

# Inside httpd.conf
RewriteEngine on
RewriteCond %{REMOTE_USER}	!^$
RewriteRule ^/some_page.html	/path/to/${REMOTE_USER}s_page.html

If you're logged in as "jonathan" this will replace the contents of
"some_page.html" with "jonathans_page.html"

If you have server side includes enabled, you can alter the contents of a
web page on the fly like so:

<!-- Inside a web page -->
<!-- #if expr="$REMOTE_USER = jonathan" -->
  Jonathan's secret content
<!-- #else -->
  Nothing to see here.
<!-- #endif -->

It sounds like the last one is what you're looking for.




More information about the Kclug mailing list