{server:variable}

Description

Returns the value of one PHP $_SERVER entry as a string - for example REMOTE_ADDR (the visitor IP address), HTTP_HOST (the requested host name), REQUEST_URI (the path and query string) or REQUEST_METHOD (GET or POST). An entry that is not set gives an empty string. Since November 2026 only the usual values of the request and the server are given: the host, scheme, port, URI and method, the script and server names, the visitor address, browser and referer, the Accept, Sec-Fetch and forwarding headers, the three basic client hints (Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform) and the like. Any other name - the cookies (HTTP_COOKIE), credentials (HTTP_AUTHORIZATION, PHP_AUTH_USER, PHP_AUTH_PW, REMOTE_USER), other headers and the environment variables of the web server - gives an empty string, and State Check lists, for the last 30 days, each refused name the web server had a value for, with a page that asked for it. For a cookie use the cookie command, for the logged-in user the user command. An install not updated since gives any entry. The value comes from the live request, so the same template can print different values for different visitors. Behind a trusted reverse proxy (AA_TRUSTED_PROXIES) AA replaces REMOTE_ADDR, HTTP_HOST, SERVER_NAME, HTTPS and SERVER_PORT with the values the proxy forwarded. Mind the page cache of the Site module: reading a value the cache key already holds or that never changes on a site (REQUEST_METHOD, SCRIPT_NAME, DOCUMENT_ROOT, SERVER_SOFTWARE and similar) costs nothing; reading the host, scheme, port, URI or HTTP_X_REQUESTED_WITH (HTTP_HOST, SERVER_NAME, SERVER_PORT, HTTPS, REQUEST_SCHEME, REQUEST_URI, QUERY_STRING) stores the page once per value read, and a URI carrying an ad click id such as gclid keeps it out of the cache; reading a value that may belong to the visitor - REMOTE_ADDR, HTTP_USER_AGENT, HTTP_REFERER, HTTP_ACCEPT_LANGUAGE and the like - keeps the whole page out of the cache. So use the visitor-specific entries only on pages that really need them. Common uses: branch on the host to build absolute links or enforce one canonical domain, and show or log the client address, often with gethostbyaddr for a reverse-DNS name.

Parameters

variable required default (none - you must name a variable)

The name of the PHP $_SERVER entry to read, for example REMOTE_ADDR, HTTP_HOST, REQUEST_URI, or REQUEST_METHOD. The value is returned as a string exactly as the web server set it. If the named entry does not exist, the result is an empty string. Since November 2026 only the usual request and server values are given (see the allowed values below); cookies, credentials, other headers and the environment variables of the web server give an empty string.

Allowed values The usual request and server values. The most useful ones: REMOTE_ADDR (visitor IP address), HTTP_HOST (requested host name), REQUEST_URI (path and query string of the request), QUERY_STRING (query string without the leading question mark), HTTPS (non-empty when the request used HTTPS), SERVER_NAME (host name from the server configuration), HTTP_USER_AGENT (browser User-Agent), HTTP_REFERER (page that linked here, if sent), REQUEST_METHOD (GET, POST, and so on), HTTP_X_REQUESTED_WITH (XMLHttpRequest for a request sent by a script). Also given: SERVER_PORT, REQUEST_SCHEME, SCRIPT_NAME, SCRIPT_FILENAME, PHP_SELF, DOCUMENT_ROOT, REDIRECT_URL, SERVER_ADDR, SERVER_SOFTWARE, SERVER_PROTOCOL, REMOTE_PORT, REQUEST_TIME, REQUEST_TIME_FLOAT, PATH_INFO, the HTTP_ACCEPT and HTTP_SEC_FETCH headers, the client hints HTTP_SEC_CH_UA, HTTP_SEC_CH_UA_MOBILE and HTTP_SEC_CH_UA_PLATFORM, HTTP_ORIGIN, HTTP_DNT, HTTP_IF_MODIFIED_SINCE, the forwarding headers such as HTTP_X_FORWARDED_FOR, GEOIP_COUNTRY_CODE and a few more. Not given since November 2026: HTTP_COOKIE, HTTP_AUTHORIZATION, PHP_AUTH_USER, PHP_AUTH_PW, REMOTE_USER, other headers and the environment variables of the web server.

Examples

virtual{server:REMOTE_ADDR}
Expected(the visitor IP address, for example 203.0.113.7)
Actual216.73.216.213
Prints the address the request came from. It differs for every visitor, and reading it keeps the page out of the Site module page cache. Behind a reverse proxy listed in AA_TRUSTED_PROXIES (by default a proxy on the same machine) AA puts the visitor address from X-Forwarded-For here; behind any other proxy it is the address of that proxy.
virtual{server:HTTP_HOST}
Expectedactionapps.org
Actualactionapps.org
HTTP_HOST is the host name from the request Host header. Useful for building absolute links or telling environments apart. Depends on how the page was reached.
virtual{server:REQUEST_URI}
Expected(the path and query string of this request, for example /aadev/view.php?vid=143)
Actual/expression/server
REQUEST_URI is the path and query string of the current request. Depends on the URL being viewed.
virtual{gethostbyaddr:{server:REMOTE_ADDR}}
Expected(the reverse-DNS name of the visitor address, for example host-203-0-113-7.example.net, or the address itself when it has no name)
Actual216.73.216.213
The canonical pairing: read the client IP with server, then resolve it to a host name with gethostbyaddr. Both the IP and its DNS name are runtime-dependent.
virtual{ifeq:{server:HTTP_HOST}:actionapps.org:live site:other host}
Expectedlive site
Actuallive site
Compare the current host with ifeq to switch behaviour per environment - here it prints "live site" only on actionapps.org. The same test guards a canonical-domain redirect in production: {redirect:{ifeq:{server:HTTP_HOST}:www.example.org::https://www.example.org{go}}} sends visitors on any other host to the canonical one. Output depends on the host, so this is illustrative.
test{server:REQUEST_METHOD}
ExpectedGET
ActualGET
GET for an ordinary page view, POST when a form was sent to the page. The page cache key already holds the request method, so reading it does not affect the page cache. Pages in this reference are always read with GET.
test{ifeq:{server:REQUEST_METHOD}:POST:Thank you for sending the form:Please fill in the form}
ExpectedPlease fill in the form
ActualPlease fill in the form
One page both shows a form and thanks the visitor after it was sent: branch on the request method. Here the page is read with GET, so the second branch is printed.
test[{server:THIS_KEY_DOES_NOT_EXIST}]
Expected[]
Actual[]
When the named $_SERVER entry is not set, the command returns an empty string. The square brackets here are literal text to make the empty result visible; they are not part of the syntax.