Here the focus is on identifying mod_rewrite variables and defining the limits of the module by checking the mod_rewrite source code.
HTTP Variables
SSL Variables
20020903:12
RewriteCond %{API_VERSION} ^(.*)$ RewriteRule .* https://www.askapache.com?API_VERSION=%1 [R=307,L]
Digest
RewriteRule .* - [E=IN_AUTH_TYPE:%{AUTH_TYPE}] RequestHeader set AUTH_TYPE "%{IN_AUTH_TYPE}e"
max-age=0
RewriteCond %{ENV:CACHE_CONTROL} no-cache [NC] RewriteRule . %{REQUEST_URI}?nocache [L]
keep-alive
(null)
RewriteCond %{REQUEST_METHOD} =POST RewriteCond %{HTTP:Content-Length}%{CONTENT_LENGTH} ^$ RewriteRule .* - [F,NS,L]
(null)
/web/webroot/askapache.com
RewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI}/index.html -f RewriteRule . /cache%{REQUEST_URI}/index.html
www.askapache.com
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC] RewriteRule . https://www.askapache.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP:Accept-Encoding} gzip [NC] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.gz -f RewriteRule . %{REQUEST_URI}.gz [L]
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
__qca=1176541205adf28-5553185; ASKAPACHEID=fdadfa4f33e62a878468; __utmc=1df3893
RewriteCond %{HTTP_COOKIE} ^.*autostart=on.*$ RewriteRule ^(.*)\.swf$ /$1?autostart=true [NE,L]
www.askapache.com
https://www.askapache.com/pro/mod_rewrite/catch.php?k=i
RewriteCond %{HTTP_REFERER} badhost [NC] RewriteRule . - [F]
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Firefox/3.0.1
RewriteCond %{HTTP_USER_AGENT} ^.*(Android|2\.0 MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|EudoraWeb|hiptop|IEMobile|iPhone).*$ [NC] RewriteRule ^(.+)$ /mobile/$1 [L]
false
300
/bin:/usr/bin:/sbin:/usr/sbin
k=i
RewriteCond %{QUERY_STRING} showtime [NC] RewriteCond T:%{TIME}_TY:%{TIME_YEAR}_TMO:%{TIME_MON}_TWD:%{TIME_WDAY}_TD:%{TIME_DAY}_TH:%{TIME_HOUR}_TMI:%{TIME_MIN}_TS:%{TIME_SEC} ^(.*)$ RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}?time=%1 [R,L]
22.162.134.211
RewriteCond %{REMOTE_ADDR} !^22\.162\.134\.211$ RewriteRule . https://www.askapache.com/maintenance-in-progress.html [R=307,L]
22.162.134.211
4220
askapache
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
/web/webroot/askapache.com/pro/mod_rewrite/index.php
GET
RewriteCond %{REQUEST_METHOD} !^(POST|GET|HEAD|PROPFIND|OPTIONS)$ RewriteRule .* - [F,L]
HTTP/1.1
RewriteCond %{REQUEST_PROTOCOL} !^HTTP/(0\.9|1\.[01])$ RewriteRule . [F,L]
/pro/mod_rewrite/index.php
RewriteCond %{REQUEST_URI} ^(robots\.txt|favicon\.ico)$ [NC] RewriteRule . - [S=1] RewriteCond %{HTTP_HOST} ^www RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
/web/webroot/askapache.com/pro/mod_rewrite/index.php
daemong
https://www.askapache.com/pro/mod_rewrite/index.php
/pro/mod_rewrite/index.php
askapache
208.113.134.190
webmaster@askapache.com
www.askapache.com
80
HTTP/1.1
Apache/2.0.61 (Unix) PHP/5.5 OpenSSL/0.9.7e
GET /pro/mod_rewrite/index.php?k=i HTTP/1.1
RewriteCond %{THE_REQUEST} ^(GET|POST) /.*?(s|search)=(.+) HTTP/ [NC] RewriteRule .* https://www.askapache.com/search/%3/? [R=302,L,NE]
20080915152142
RewriteCond %{QUERY_STRING} showtime [NC] RewriteCond T:%{TIME}_TY:%{TIME_YEAR}_TMO:%{TIME_MON}_TWD:%{TIME_WDAY}_TD:%{TIME_DAY}_TH:%{TIME_HOUR}_TMI:%{TIME_MIN}_TS:%{TIME_SEC} ^(.*)$ RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}?time=%1 [R,L]
15
15
21
09
42
1
2008
qOr5tEBvcm8AAE-VoiUAAAAQ
off
RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
DHE-RSA-AES256-SHA
256
false
256
NONE
TLSv1
rsaEncryption
sha1WithRSAEncryption
-----BEGIN CERTIFICATE----- ... MIIFkTC ... -----END CERTIFICATE-----
/C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./OU=http://certificates.starfieldtech.com/repository/CN=Starfield Secure Certification Authority/serialNumber=10688435
US
Starfield Secure Certification Authority
Scottsdale
Starfield Technologies, Inc.
http://certificates.starfieldtech.com/repository
Arizona
042840B88A2352
3
/O=www.askapache.com/OU=Domain Control Validated/CN=www.askapache.com
www.askapache.com
www.askapache.com
Domain Control Validated
Jul 14 16:53:43 2012 GMT
Jul 14 20:25:17 2010 GMT
4184083DD1C74547553018174950D88987BD7ED03CE54EBB6638539C34814376
mod_ssl/2.2.16
OpenSSL/0.9.8e-fips-rhel5
# 300 5 MIN # 600 10 MIN # 900 15 MIN # 1800 30 MIN # 2700 45 MIN # 3600 1 HR # 7200 2 HR # 10800 3 HR # 14400 4 HR # 18000 5 HR # 36000 10 HR # 39600 11 HR # 43200 12 HR # 46800 13 HR # 50400 14 HR # 54000 15 HR # 86400 1 DAY # 172800 2 DAY # 259200 3 DAY # 345600 4 DAY # 432000 5 DAY # 518400 6 DAY # 604800 1 WEEK # 1209600 2 WEEK # 1814400 3 WEEK # 2419200 4 WEEK # 4838400 2 MONTH # 7257600 3 MONTH # 9676800 4 MONTH # 12096000 5 MONTH # 14515200 6 MONTH # 16934400 7 MONTH # 19353600 8 MONTH # 21772800 9 MONTH # 24192000 10 MONTH # 26611200 11 MONTH # 29030400 12 MONTH
For a broader mod_rewrite cheat sheet, check this printable cheat sheet.
RewriteEngine on|offOn or Off to enable or disable (default) the whole rewriting engine
RewriteOptions OptionsList of option strings to set
RewriteBase URL-paththe base URL of the per-directory context
RewriteCond TestString CondPatternan input string and a to be applied regexp-pattern
RewriteRule Pattern Substitution [flags]an URL-applied regexp-pattern and a substitution URL
RewriteMap MapName MapType:MapSourcea mapname and a filename
RewriteLock file-paththe filename of a lockfile used for inter-process synchronization
RewriteLog file-paththe filename of the rewriting logfile
RewriteLogLevel Levelthe level of the rewriting logfile verbosity (0=none, 1=std, .., 9=max)
RewriteRule
(^/.*$) is checked first.RewriteRule
is applied.cookie|CO=Name:Value:Domain[:Lifetime[:Path]]
'env|E=VAR:VAL' (set environment variable)
RewriteRule (root|cmd)\.exe - [E=worm:nimda]
'forbidden|F' (force URL to be forbidden)
'gone|G' (force URL to be gone)
'handler|H=Content-handler' (force Content handler)
'last|L' (last rule)
'next|N' (next round)
'nocase|NC' (no case)
'noescape|NE' (no URI escaping of output)
'nosubreq|NS' (not for internal sub-requests)
'proxy|P' (force proxy)
'passthrough|PT' (pass through to next handler)
'qsappend|QSA' (query string append)
'redirect|R [=code]' (force redirect)
'skip|S=num' (skip next rule(s))
'type|T=MIME-type' (force MIME type)
"%d:%d",MODULE_MAGIC_NUMBER_MAJOR,MODULE_MAGIC_NUMBER_MINOR)
ap_auth_type
ap_document_root(r)
lookup_header("Accept", ctx)
lookup_header("Cookie", ctx)
lookup_header("Forwarded", ctx)
lookup_header("Host", ctx)
lookup_header("Proxy-Connection", ctx)
lookup_header("Referer", ctx)
flag ? "on" : "off"
lookup_header("User-Agent", ctx)
(main ? "true" : "false")
path_info
args
connection->remote_ip
ap_get_remote_logname(r)
r->connection->remote_addr->port
user
same as script_filename
method
uri
same as request_filename
unknown
unknown
connection->local_ip
server->server_admin
ap_get_server_name(r)
ap_get_server_port(r)
protocol
ap_get_server_banner()
the_request
%04d%02d%02d%02d%02d%02d
HTTP_MOVED_PERMANENTLY
HTTP_MOVED_TEMPORARILY
HTTP_SEE_OTHER
This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly.
It supports an unlimited number of additional rule conditions (which can operate on a lot of variables, even on HTTP headers) for granular matching and even external database lookups (either via plain text tables, DBM hash files or even external processes) for advanced URL substitution.
It operates on the full URLs (including the PATH_INFO part) both in per-server context (httpd.conf) and per-dir context (.htaccess) and even can generate QUERY_STRING parts on result. The rewriting result finally can lead to internal subprocessing, external request redirection or even to internal proxy throughput.
This module was originally written in April 1996 and gifted exclusively to the The Apache Software Foundation in July 1997 by
Ralf S. Engelschall rse [at] engenschall.com
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: %s
RewriteCond: bad argument line
RewriteCond: NoCase option for non-regex pattern %s is not supported and will be ignored.
RewriteCond: cannot compile regular expression
RewriteRule: invalid HTTP response code %s for flag R
RewriteRule: unknown flag
RewriteRule: cannot compile regular expression
RewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored.
RewriteOptions: unknown option
RewriteMap: bad path to txt map:
RewriteMap: bad path to rnd map:
RewriteMap: bad map:
RewriteMap: bad path to dbm map:
RewriteMap: dbm type
RewriteMap: bad path to prg map:
RewriteMap: internal map not found:
RewriteMap: bad path to txt map:
RewriteMap: file for map not found:
Invalid RewriteLock path
RewriteBase: only valid in per-directory config files
RewriteBase: empty URL not allowed
RewriteBase: argument is not a valid URL
RewriteCond: bad flag delimiters
RewriteCond: unknown flag
RewriteLog and RewriteLogLevel are not supported by this build of mod_rewrite because it was compiled using the -DREWRITELOG_DISABLED compiler option. You have to recompile mod_rewrite WITHOUT this option in order to use the rewrite log.
mod_rewrite: Invalid RewriteLog path %s
mod_rewrite: could not open reliable pipe to RewriteLog filter %s
mod_rewrite: Invalid RewriteLog path %s
mod_rewrite: could not open RewriteLog file %s
mod_rewrite: Running external rewrite maps without defining a RewriteLock is DANGEROUS!
mod_rewrite: could not start RewriteMap program %s
mod_rewrite: cant access text RewriteMap file %s
mod_rewrite: cant access DBM RewriteMap file %s
mod_rewrite: Parent could not create RewriteLock file %s
mod_rewrite: Parent could not set permissions on RewriteLock check User and Group directives
mod_rewrite: could not create rewrite_log_lock
mod_rewrite: Could not set permissions on rewrite_log_lock check User and Group directives
mod_rewrite: could not init rewrite_mapr_lock_acquire in child
mod_rewrite: could not init rewrite log lock in child
mod_rewrite: could not init map cache in child
split uri=%s -> uri=%s, args=%s
reduce %s -> %s
strip matching prefix: %s -> %s
add subst prefix: %s -> %s
cant open RewriteMap file, see error log
cache lookup FAILED, forcing new map lookup
map lookup FAILED: map=%s[txt] key=%s
map lookup OK: map=%s[txt] key=%s -> val=%s
cache lookup OK: map=%s[txt] key=%s -> val=%s
randomly chosen the subvalue `%s
cant open DBM RewriteMap file, see error log
cache lookup FAILED, forcing new map lookup
map lookup FAILED: map=%s[dbm] key=%s
map lookup OK: map=%s[dbm] key=%s -> val=%s
cache lookup OK: map=%s[dbm] key=%s -> val=%s
map lookup FAILED: map=%s key=%s
map lookup OK: map=%s key=%s -> val=%s
map lookup FAILED: map=%s key=%s
map lookup OK: map=%s key=%s -> val=%s
lookahead: path=%s var=%s -> val=%s
lookahead: path=%s var=%s -> val=%s
RESULT=%s
escaping backreference %s to %s
setting env variable %s to %s
setting cookie %s, cookie
skipping already set cookie %s
RewriteCond URI (-U) check: path=%s -> status=%d
RewriteCond file (-F) check: path=%s -> file=%s status=%d
RewriteCond: input=%s pattern=%s%s%s%s => %s
remember %s to have MIME-type %s
remember %s to have Content-handler %s
add path info postfix: %s -> %s%s
strip per-dir prefix: %s -> %s
applying pattern %s to uri %s
rewrite %s -> %s, ctx->uri
forcing responsecode %d for %s
add per-dir prefix: %s -> %s%s
forcing proxy-throughput with %s
explicitly forcing redirect with %s
implicitly forcing redirect (rc=%d) with %s
forcing %s to get passed through to next API URI-to-filename handler
init rewrite engine with requested uri %s
go-ahead with proxy request %s [OK]
dconf->directory,trying to replace prefix %s with %s
escaping %s for redirect
redirect to %s [REDIRECT/%d]
initial URL equal rewritten URL: %s [IGNORING REWRITE]
dconf->directory, trying to replace prefix %s with %s
strip document_root prefix: %s -> %s
internal redirect with %s [INTERNAL REDIRECT]
pass through %s
force filename %s to have MIME-type %s
force filename %s to have the Content-handler %s,
init rewrite engine with requested uri %s
init rewrite engine with passed filename %s. Original uri = %s
uri already rewritten. Status %s, Uri %s, %s
attempt to make remote request from mod_rewrite without proxy enabled: %s
go-ahead with proxy request %s [OK]
escaping %s for redirect
redirect to %s [REDIRECT/%d]
local path result: %s
prefixing with document_root of %s FAILED
prefixed with document_root to %s
go-ahead with %s [OK]
pass through %s