iTP Secure WebServer System Administrator's Guide (iTPWebSvr 6.0+)
Configuring the iTP Secure WebServer
iTP Secure WebServer System Administrator’s Guide—523346-002
7-40
Using Tcl Variables
Example 1: Time of Day Variables
For example, you can use the YEAR, MONTH, DAY, WEEKDAY, HOUR, and MINUTE
variables to trigger different types of access based on the time of day, as shown in the
following example:
Region /pictures/* {
if {$HOUR > 7 && $HOUR < 19} {
Redirect /come-back-later.html
}
}
In this example, the Region directive limits access to the /pictures area. Any users
attempting to access this area between 7AM and 7PM (local server time) will be
directed to the /come-back-later.html document.
Example 2: REMOTE_HOST and REMOTE_ADDR Variables
You can use the REMOTE_HOST and REMOTE_ADDR variable (containing the host name
of the web client making a request) or the REMOTE_ADDR variable (containing the IP
address of the web client) with the Tcl switch command:
Region / {
switch $REMOTE_HOST {
*.mit.edu {Redirect /mit/home.html}
*.cornell.edu {Redirect /cornell/home.html}
*.yale.edu {Redirect /yale/home.html}
*.wvu.edu {Redirect /wvu/home.html}
}
}
In this example, the switch command directs requests to different home pages on the
basis of the origin of each request.
Example 3: HEADER Variable
The HEADER array variable contains any HTTP headers sent by a web client, including
the headers containing the web client software type and the referring URL. The
indexes of the array elements consist of the header names, converted to lowercase,
with no trailing colon. For example, the HTTP header
User-Agent:
would be stored as array element
HEADER(user-agent)
Because clients do not have to send headers, Region commands using the HEADER
variable should first check for the existence of a HEADER array entry, by using the Tcl
info exists command.
For example, assume the Dinosaur/1.0 browser fails whenever it attempts to use a
particular CGI program and you wish to direct all Dinosaur/1.0 users to an