2.7.1.1.13. .htaccess variables

A number of variables containing information about the request and its originator are available for use in various request-handling rules and when constructing regular expressions in .htaccess. All variables are specified in curly braces with a percent sign at the beginning, for example, %{HTTP_HOST}. Additional information is available in the Apache documentation.

Variable Description Example
HTTP request headers
HTTP_USER_AGENT The sender's User-Agent, as included in the request. Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
HTTP_REFERER The Referer header, which may be sent when navigating from one web page to another. https://domain.com/
HTTP_COOKIE The cookie data included in the request. dom=sometesttextstoredincoockie
HTTP_HOST The domain from the HOST header. www.domain.com
HTTP_ACCEPT A string with a list of valid data types (content-type), separated by semicolons ;. text/html,application/xhtml+xml,application/xml;q=0.8,application/signed-exchange;v=b3;q=0.9
Request parameters
REMOTE_ADDR The IP address of the request sender. 123.213.231.211
REQUEST_METHOD The request type as a string, such as GET, POST, PUT, and others. GET
REQUEST_TIME The timestamp 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 The GET parameters as a string. If there are no GET parameters or only the character ? is present, an empty string will be returned. var1=text&var2=text
SERVER_ADMIN The email address of the hosting service administrator (owner). mail@domain.com
SERVER_NAME The name of the virtual host (site) that is processing the request. www.domain.com
TIME_YEAR The year of the request processing date. 2023
TIME_MON The month of the request processing date ranges from 1 to 12. 03
TIME_DAY The day of the request processing date ranges from 1 to 28-31. 02
TIME_HOUR The hour of the request processing date. 05
TIME_MIN The minute of the request processing date. 23
TIME_SEC The second of the request processing date. 32
TIME_WDAY The weekday of the request processing date ranges from 0 to 6. 1
TIME The date of the request processing date, in the format YearMonthDayHourMinuteSecond without separators: YYYYMMDDHHMMSS. 20230302052332
REQUEST_URI The URL of the request, including GET parameters but excluding the domain. /script.php?var1=text&var2=text
REQUEST_FILENAME The absolute path to the script file. /home/example/domain.com/www/script.php
Content