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:12RewriteCond %{API_VERSION} ^(.*)$
RewriteRule .* https://www.askapache.com?API_VERSION=%1 [R=307,L]DigestRewriteRule .* - [E=IN_AUTH_TYPE:%{AUTH_TYPE}]
RequestHeader set AUTH_TYPE "%{IN_AUTH_TYPE}e"max-age=0RewriteCond %{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.comRewriteCond %{DOCUMENT_ROOT}/cache%{REQUEST_URI}/index.html -f
RewriteRule . /cache%{REQUEST_URI}/index.htmlwww.askapache.comRewriteCond %{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=1df3893RewriteCond %{HTTP_COOKIE} ^.*autostart=on.*$
RewriteRule ^(.*)\.swf$ /$1?autostart=true [NE,L]www.askapache.comhttps://www.askapache.com/pro/mod_rewrite/catch.php?k=iRewriteCond %{HTTP_REFERER} badhost [NC]
RewriteRule . - [F]Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Firefox/3.0.1RewriteCond %{HTTP_USER_AGENT} ^.*(Android|2\.0 MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|EudoraWeb|hiptop|IEMobile|iPhone).*$ [NC]
RewriteRule ^(.+)$ /mobile/$1 [L]false300/bin:/usr/bin:/sbin:/usr/sbink=iRewriteCond %{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.211RewriteCond %{REMOTE_ADDR} !^22\.162\.134\.211$
RewriteRule . https://www.askapache.com/maintenance-in-progress.html [R=307,L]22.162.134.2114220askapacheRewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]/web/webroot/askapache.com/pro/mod_rewrite/index.phpGETRewriteCond %{REQUEST_METHOD} !^(POST|GET|HEAD|PROPFIND|OPTIONS)$
RewriteRule .* - [F,L]HTTP/1.1RewriteCond %{REQUEST_PROTOCOL} !^HTTP/(0\.9|1\.[01])$
RewriteRule . [F,L]/pro/mod_rewrite/index.phpRewriteCond %{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.phpdaemonghttps://www.askapache.com/pro/mod_rewrite/index.php/pro/mod_rewrite/index.phpaskapache208.113.134.190webmaster@askapache.comwww.askapache.com80HTTP/1.1Apache/2.0.61 (Unix) PHP/5.5 OpenSSL/0.9.7eGET /pro/mod_rewrite/index.php?k=i HTTP/1.1RewriteCond %{THE_REQUEST} ^(GET|POST) /.*?(s|search)=(.+) HTTP/ [NC]
RewriteRule .* https://www.askapache.com/search/%3/? [R=302,L,NE]20080915152142RewriteCond %{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]151521094212008qOr5tEBvcm8AAE-VoiUAAAAQoffRewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]DHE-RSA-AES256-SHA256false256NONETLSv1rsaEncryptionsha1WithRSAEncryption-----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=10688435USStarfield Secure Certification AuthorityScottsdaleStarfield Technologies, Inc.http://certificates.starfieldtech.com/repositoryArizona042840B88A23523/O=www.askapache.com/OU=Domain Control Validated/CN=www.askapache.comwww.askapache.comwww.askapache.comDomain Control ValidatedJul 14 16:53:43 2012 GMTJul 14 20:25:17 2010 GMT4184083DD1C74547553018174950D88987BD7ED03CE54EBB6638539C34814376mod_ssl/2.2.16OpenSSL/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_typeap_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_infoargsconnection->remote_ipap_get_remote_logname(r)r->connection->remote_addr->portusersame as script_filenamemethodurisame as request_filenameunknownunknownconnection->local_ipserver->server_adminap_get_server_name(r)ap_get_server_port(r)protocolap_get_server_banner()the_request%04d%02d%02d%02d%02d%02dHTTP_MOVED_PERMANENTLYHTTP_MOVED_TEMPORARILYHTTP_SEE_OTHERThis 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: %sRewriteCond: bad argument lineRewriteCond: NoCase option for non-regex pattern %s is not supported and will be ignored.RewriteCond: cannot compile regular expressionRewriteRule: invalid HTTP response code %s for flag RRewriteRule: unknown flagRewriteRule: cannot compile regular expressionRewriteOptions: MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored.RewriteOptions: unknown optionRewriteMap: bad path to txt map:RewriteMap: bad path to rnd map:RewriteMap: bad map:RewriteMap: bad path to dbm map:RewriteMap: dbm typeRewriteMap: bad path to prg map:RewriteMap: internal map not found:RewriteMap: bad path to txt map:RewriteMap: file for map not found:Invalid RewriteLock pathRewriteBase: only valid in per-directory config filesRewriteBase: empty URL not allowedRewriteBase: argument is not a valid URLRewriteCond: bad flag delimitersRewriteCond: unknown flagRewriteLog 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 %smod_rewrite: could not open reliable pipe to RewriteLog filter %smod_rewrite: Invalid RewriteLog path %smod_rewrite: could not open RewriteLog file %smod_rewrite: Running external rewrite maps without defining a RewriteLock is DANGEROUS!mod_rewrite: could not start RewriteMap program %smod_rewrite: cant access text RewriteMap file %smod_rewrite: cant access DBM RewriteMap file %smod_rewrite: Parent could not create RewriteLock file %smod_rewrite: Parent could not set permissions on RewriteLock check User and Group directivesmod_rewrite: could not create rewrite_log_lockmod_rewrite: Could not set permissions on rewrite_log_lock check User and Group directivesmod_rewrite: could not init rewrite_mapr_lock_acquire in childmod_rewrite: could not init rewrite log lock in childmod_rewrite: could not init map cache in childsplit uri=%s -> uri=%s, args=%sreduce %s -> %sstrip matching prefix: %s -> %sadd subst prefix: %s -> %scant open RewriteMap file, see error logcache lookup FAILED, forcing new map lookupmap lookup FAILED: map=%s[txt] key=%smap lookup OK: map=%s[txt] key=%s -> val=%scache lookup OK: map=%s[txt] key=%s -> val=%srandomly chosen the subvalue `%scant open DBM RewriteMap file, see error logcache lookup FAILED, forcing new map lookupmap lookup FAILED: map=%s[dbm] key=%smap lookup OK: map=%s[dbm] key=%s -> val=%scache lookup OK: map=%s[dbm] key=%s -> val=%smap lookup FAILED: map=%s key=%smap lookup OK: map=%s key=%s -> val=%smap lookup FAILED: map=%s key=%smap lookup OK: map=%s key=%s -> val=%slookahead: path=%s var=%s -> val=%slookahead: path=%s var=%s -> val=%sRESULT=%sescaping backreference %s to %ssetting env variable %s to %ssetting cookie %s, cookieskipping already set cookie %sRewriteCond URI (-U) check: path=%s -> status=%dRewriteCond file (-F) check: path=%s -> file=%s status=%dRewriteCond: input=%s pattern=%s%s%s%s => %sremember %s to have MIME-type %sremember %s to have Content-handler %sadd path info postfix: %s -> %s%sstrip per-dir prefix: %s -> %sapplying pattern %s to uri %srewrite %s -> %s, ctx->uriforcing responsecode %d for %sadd per-dir prefix: %s -> %s%sforcing proxy-throughput with %sexplicitly forcing redirect with %simplicitly forcing redirect (rc=%d) with %sforcing %s to get passed through to next API URI-to-filename handlerinit rewrite engine with requested uri %sgo-ahead with proxy request %s [OK]dconf->directory,trying to replace prefix %s with %sescaping %s for redirectredirect to %s [REDIRECT/%d]initial URL equal rewritten URL: %s [IGNORING REWRITE]dconf->directory, trying to replace prefix %s with %sstrip document_root prefix: %s -> %sinternal redirect with %s [INTERNAL REDIRECT]pass through %sforce filename %s to have MIME-type %sforce filename %s to have the Content-handler %s,init rewrite engine with requested uri %sinit rewrite engine with passed filename %s. Original uri = %suri already rewritten. Status %s, Uri %s, %sattempt to make remote request from mod_rewrite without proxy enabled: %sgo-ahead with proxy request %s [OK]escaping %s for redirectredirect to %s [REDIRECT/%d]local path result: %sprefixing with document_root of %s FAILEDprefixed with document_root to %sgo-ahead with %s [OK]pass through %s