Standard server variables

Echoing server variables in your HTML document is a way to provide dynamic content without resorting to CGI programming. For example, in the paragraph below I used <!--#echo var="http_host" --> and <!--#echo var="date_gmt" --> to supply my domain name and the current Greenwich Mean Time:

Hello and welcome to kgraff.net on Monday, 25-May-2020 13:04:36 GMT .

A Perl CGI alternative for date and time display and manipulation.

If you click your browser's Reload or Refresh button, the displayed time will update.

Syntax:   <!--#echo var="VARIABLE_NAME" -->

Note:  Some servers require the variable names to be in ALL CAPS. Which server variables you can use, the ones in the table below with server responses other than (none) for my site, depends on how your hosting supplier configured the web server software, Apache in this case. Some servers require an .shtml extension in pages that call environment variables.

Below are selected enviroment variables and the response on this server. See the documentation for the web server software used on your site for a full list of available variables.

variable name server response
date_local Monday, 25-May-2020 06:04:36 PDT
date_gmt Monday, 25-May-2020 13:04:36 GMT
document_name env_var.shtml
document_root /home/kgraff/kgraff.net
document_uri /it/tutorial/env_var.shtml
gateway_interface CGI/1.1
http_cache_control (none)
http_connection Keep-Alive
http_host kgraff.net
http_user_agent CCBot/2.0 (https://commoncrawl.org/faq/)
last_modified Saturday, 24-Jul-2010 16:30:13 PDT
request_method GET
request_uri /it/tutorial/env_var.shtml
script_filename /home/kgraff/kgraff.net/it/tutorial/env_var.shtml
script_name /it/tutorial/env_var.shtml
script_uri http://kgraff.net/it/tutorial/env_var.shtml
script_url /it/tutorial/env_var.shtml
server_name kgraff.net
server_port 80
server_protocol HTTP/1.1
server_software Apache
web design * database * Macintosh OS X * Linux * UNIX