2.7.1.1.13. .htaccess variables

For use in various request processing and generation rules regular expressions some variables are available in .htaccess with some information about the request and its sender. All variables are specified in curly braces with a percent sign at the beginning, for example %{HTTP_HOST}. Some additional access information in Apache documentation.

Variable Description Example
HTTP request headers
HTTP_USER_AGENT The sender's User-Agent passed in the request. Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
HTTP_REFERER heading Referer, which can be passed when navigating from one web page to another. https://domain.com/
HTTP_COOKIE Data cookieThe passed in the request. dom=sometesttextstoredincoockie
HTTP_HOST Domain from header HOST. www.domain.com
HTTP_ACCEPT A string with a list of allowed types of transmitted data (content-type) separated by a semicolon ;. text/html,application/xhtml+xml,application/xml;q=0.8,application/signed-exchange;v=b3;q=0.9
Request parameters
REMOTE_ADDR Request sender's IP address. 123.213.231.211
REQUEST_METHOD Request type as a string, for example GET, POST, PUT and others. GET
REQUEST_TIME Request time in Unix format. 1675723794
Web server data
SCRIPT_FILENAME The absolute path to the script file. /home/example/domain.com/www/script.php
QUERY_STRING GET parameter data as a string. If there are no GET parameters or if there is only a symbol ? an empty string will be returned. var1=text&var2=text
SERVER_ADMIN The mailbox of the administrator (owner) of the hosting service. mail@domain.com
SERVER_NAME The name of the virtual host (site) that processes the request. www.domain.com
TIME_YEAR The year in which the request was processed. 2023
TIME_MON Month of the request processing date from 1 to 12. 03
TIME_DAY Day of request processing date from 1 to 28-31. 02
TIME_HOUR The hour of the request processing date. 05
TIME_MIN The minute of the date the request was processed. 23
TIME_SEC The second of the request processing date. 32
TIME_WDAY The day of the week of the request processing date, from 0 to 6. 1
TIME Request processing date in the form YearMonthDayHourMinuteSecond without separators YYYYMMDDhhmmss. 20230302052332
REQUEST_URI Request URL with GET parameters but no domain. /script.php?var1=text&var2=text
REQUEST_FILENAME The absolute path to the script file. /home/example/domain.com/www/script.php
Content