Glossary¶
- .htaccess¶
A per-directory configuration file, placed in a directory served by httpd, that applies directives to that directory and its children. Rewrite rules in
.htaccessbehave differently than those in server config — see RewriteBase and Chapter 3.- AllowOverride¶
A directive that controls which types of directives are permitted in
.htaccessfiles.AllowOverride Allenables everything;AllowOverride None(the 2.4 default) disables.htaccessentirely.- Apache HTTP Server¶
The web server software, commonly called “httpd.” This book covers version 2.4 and later, with notes on trunk (future 2.5.x) features.
- backreference¶
A captured group from a regular expression match, referenced as
$1through$9inRewriteRulesubstitutions and%1through%9forRewriteCondcaptures.$0and%0refer to the entire matched string.- CGI¶
Common Gateway Interface — a protocol for web servers to execute external programs and return their output as HTTP responses.
ScriptAliasdesignates a directory whose contents are treated as CGI programs.- CondPattern¶
The second argument to
RewriteCond— the pattern or expression that theTestStringis compared against.- content negotiation¶
The process by which httpd selects the best representation of a resource based on the client’s
Accept-*headers.mod_negotiationandMultiViewsimplement this. See Chapter 2.- directive¶
A configuration command in the httpd configuration file (or
.htaccess). Examples:RewriteRule,DocumentRoot,ProxyPass.- DocumentRoot¶
The directory from which httpd serves static files by default. A request for
/page.htmlmaps toDocumentRoot/page.html.- ErrorDocument¶
A directive that specifies a custom response for a given HTTP status code.
ErrorDocument 404 /not-found.htmlserves a custom 404 page.- FallbackResource¶
A
mod_dirdirective that specifies a default handler for requests that don’t match any existing file — the mechanism behind most front-controller frameworks. See Chapter 2.- flag¶
A modifier enclosed in square brackets at the end of a
RewriteRule, such as[L],[R=301], or[P]. Flags alter how the rule is processed. See Chapter 6.- front controller¶
A web application design pattern where all requests are routed through a single entry point (typically
index.phporapp.py).FallbackResourceandmod_rewriteboth support this pattern.- handler¶
An internal httpd representation of the action to be taken when a file is called. The
[H]flag (orSetHandler) assigns a handler to matched requests.- httpd¶
The Apache HTTP Server daemon. The executable is typically called
httpdorapache2depending on the distribution.- MIME type¶
A label identifying the type of content, such as
text/htmlorimage/png. httpd uses MIME types (viamod_mime) to determine how to serve files.- mod_alias¶
The module providing
Alias,AliasMatch,Redirect,RedirectMatch,ScriptAlias, andScriptAliasMatchdirectives. Simpler and faster thanmod_rewritefor static URL mapping.- mod_proxy¶
The core proxy module. By itself it provides the framework (
ProxyPass,ProxyPassReverse); pair it with a protocol module likemod_proxy_httpormod_proxy_fcgifor actual proxying. See Chapter 9.- mod_rewrite¶
The rule-based URL rewriting engine. Uses PCRE regular expressions to match and transform request URLs. The subject of most of this book.
- MultiViews¶
An
Optionssetting that enables content negotiation viamod_negotiation. A request for/docwill matchdoc.en.html,doc.fr.html, etc., based on the client’s language preferences.- PCRE¶
Perl Compatible Regular Expressions — the regex library used by
mod_rewrite. Syntax is documented inman pcre2patternorman perlre.- per-directory context¶
Configuration that applies within a
<Directory>,<DirectoryMatch>,<Files>, or<FilesMatch>block, or in a.htaccessfile. All of these are per-directory context —.htaccessis not a separate context type but simply another way to specify per-directory configuration. Rewrite rules in this context operate on the URL-path with the directory prefix stripped. SeeRewriteBaseand Chapter 3.- ProxyPass¶
The primary
mod_proxydirective for reverse proxying. Maps a local URL prefix to a backend server URL.- ProxyPassReverse¶
Rewrites
Location,Content-Location, andURIheaders in the backend’s response so redirects point to the proxy’s URL rather than the backend’s internal URL.- regex¶
Regular expression — a pattern-matching language. In the context of this book, PCRE regex as used by
RewriteRuleandRewriteCond. See Chapter 1.- reverse proxy¶
A server that accepts client requests and forwards them to one or more backend servers, returning the response as if it originated from the proxy itself.
mod_proxywithProxyPassis the standard httpd reverse proxy. The[P]flag inRewriteRulealso triggers proxying.- RewriteBase¶
A directive that sets the base URL for per-directory rewrites. Only meaningful in
.htaccessor<Directory>context. See Chapter 3.- RewriteCond¶
A directive that attaches a condition to the following
RewriteRule. The rule fires only if all preceding conditions match. See Chapter 7.- RewriteEngine¶
Enables or disables the rewriting engine. Must be set to
Onin each context (server, virtual host, directory) where you want rules to be processed.- RewriteMap¶
A directive that defines a named mapping function (text file, DBM, program, database query, or internal function) for use in
RewriteRuleandRewriteCondsubstitutions. See Chapter 8.- RewriteOptions¶
Controls special behaviors of the rewrite engine — rule inheritance, URI handling, and other edge cases. See Chapter 3.
- RewriteRule¶
The central directive of
mod_rewrite. Matches a URL pattern and transforms it into a new URL or triggers an action (redirect, proxy, forbid, etc.). See Chapter 4.- server context¶
Configuration that applies at the top level of
httpd.confor within a<VirtualHost>block, as opposed to per-directory context.- server variable¶
A value available for testing in
RewriteCondvia the%{VARIABLE_NAME}syntax. Examples:%{HTTP_HOST},%{REQUEST_URI},%{REMOTE_ADDR}. See Chapter 7.- substitution¶
The second argument to
RewriteRule— the replacement URL or path. May contain backreferences ($1), server variables, andRewriteMapexpansions.- TestString¶
The first argument to
RewriteCond— the string to test, which can contain server variables, backreferences, and map expansions.- URL mapping¶
The process by which httpd determines what resource corresponds to a requested URL. Involves
DocumentRoot,Alias,Redirect,mod_rewrite, and other modules. See Chapter 2.- URL-path¶
The path component of a URL, without the scheme, host, or query string. For
http://example.com/one/two?q=x, the URL-path is/one/two.- virtual host¶
A configuration block (
<VirtualHost>) that allows a single httpd instance to serve multiple websites. Virtual hosts can be name-based (distinguished byHost:header) or IP-based. See Chapter 10.