defines a file suffix as <code>type-map</code>; this is best done
with</p>
-<pre class="prettyprint lang-config">AddHandler type-map .var</pre>
+ <pre class="prettyprint lang-config">AddHandler type-map .var</pre>
<p>in the server configuration file.</p>
named by the <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code> directive, if the
server is trying to index a directory. If the configuration files
specify</p>
-<pre class="prettyprint lang-config">DirectoryIndex index</pre>
+ <pre class="prettyprint lang-config">DirectoryIndex index</pre>
<p>then the server will arbitrate between <code>index.html</code>
and <code>index.html3</code> if both are present. If neither
<a href="./ko/content-negotiation.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
<a href="./tr/content-negotiation.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
</div>
+<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
+ anglaise pour les changements récents.</div>
<p>Apache HTTPD supporte la négociation de
<?xml-stylesheet type="text/xsl" href="./style/manual.fr.xsl"?>
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
-<!-- English Revision : 1364312 -->
+<!-- English Revision: 1364312:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?>
-<!-- English Revision: 675610:1364312 (outdated) -->
+<!-- English Revision: 675610:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='EUC-KR' ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1364312 (outdated) -->
+<!-- English Revision: 151408:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<variants>
<variant>en</variant>
- <variant>fr</variant>
+ <variant outdated="yes">fr</variant>
<variant outdated="yes">ja</variant>
<variant outdated="yes">ko</variant>
<variant outdated="yes">tr</variant>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.tr.xsl"?>
-<!-- English Revision: 1174747:1364312 (outdated) -->
+<!-- English Revision: 1174747:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
<h3><a name="contents" id="contents">What we will be discussing in this document</a></h3>
<p>
-This document will discuss several cases where <code class="module"><a href="../mod/mod_lua.html">mod_lua</a></code> can be used
-to either ease up a phase of the request processing or create more transparency in
+This document will discuss several cases where <code class="module"><a href="../mod/mod_lua.html">mod_lua</a></code> can be used
+to either ease up a phase of the request processing or create more transparency in
the logic behind a decision made in a phase.
</p>
<h3><a name="prerequisites" id="prerequisites">Prerequisites</a></h3>
<p>
-First and foremost, you are expected to have a basic knowledge of how the Lua
-programming language works. In most cases, we will try to be as pedagogical
-as possible and link to documents describing the functions used in the
-examples, but there are also many cases where it is necessary to either
-just assume that "it works" or do some digging yourself into what the hows
-and whys of various function calls.
+First and foremost, you are expected to have a basic knowledge of how the Lua
+programming language works. In most cases, we will try to be as pedagogical
+as possible and link to documents describing the functions used in the
+examples, but there are also many cases where it is necessary to either
+just assume that "it works" or do some digging yourself into what the hows
+and whys of various function calls.
</p>
<h3>Setting a scope for Lua states</h3>
<p>
-Setting the right <code class="directive"><a href="../mod/mod_lua.html#luascope">LuaScope</a></code> setting
-for your Lua scripts can be essential to your server's
-performance. By default, the scope is set to <code>once</code>, which means
-that every call to a Lua script will spawn a new Lua state that handles that
-script and is destroyed immediately after. This option keeps the memory
-footprint of mod_lua low, but also affects the processing speed of a request.
-If you have the memory to spare, you can set the scope to <code>thread</code>,
-which will make mod_lua spawn a Lua state that lasts the entirity of a thread's
-lifetime, speeding up request processing by 2-3 times. Since mod_lua will create
-a state for each script, this may be an expensive move, memory-wise, so to
-compromise between speed and memory usage, you can choose the <code>server</code>
-option to create a pool of Lua states to be used. Each request for a Lua script or
-a hook function will then acquire a state from the pool and release it back when it's
-done using it, allowing you to still gain a significant performance increase, while
+Setting the right <code class="directive"><a href="../mod/mod_lua.html#luascope">LuaScope</a></code> setting
+for your Lua scripts can be essential to your server's
+performance. By default, the scope is set to <code>once</code>, which means
+that every call to a Lua script will spawn a new Lua state that handles that
+script and is destroyed immediately after. This option keeps the memory
+footprint of mod_lua low, but also affects the processing speed of a request.
+If you have the memory to spare, you can set the scope to <code>thread</code>,
+which will make mod_lua spawn a Lua state that lasts the entirity of a thread's
+lifetime, speeding up request processing by 2-3 times. Since mod_lua will create
+a state for each script, this may be an expensive move, memory-wise, so to
+compromise between speed and memory usage, you can choose the <code>server</code>
+option to create a pool of Lua states to be used. Each request for a Lua script or
+a hook function will then acquire a state from the pool and release it back when it's
+done using it, allowing you to still gain a significant performance increase, while
keeping your memory footprint low. Some examples of possible settings are:
</p>
<pre class="prettyprint lang-config">LuaScope once
LuaScope server 5 40</pre>
<p>
-As a general rule of thumb: If your server has none to low usage, use <code>once</code>
-or <code>request</code>, if your server has low to medium usage, use the <code>server</code>
-pool, and if it has high usage, use the <code>thread</code> setting. As your server's
-load increases, so will the number of states being actively used, and having your scope
+As a general rule of thumb: If your server has none to low usage, use <code>once</code>
+or <code>request</code>, if your server has low to medium usage, use the <code>server</code>
+pool, and if it has high usage, use the <code>thread</code> setting. As your server's
+load increases, so will the number of states being actively used, and having your scope
set to <code>once/request/conn</code> will stop being beneficial to your memory footprint.
</p>
<p>
-<strong>Note:</strong> The <code>min</code> and <code>max</code> settings for the
-<code>server</code> scope denotes the minimum and maximum states to keep in a pool per
+<strong>Note:</strong> The <code>min</code> and <code>max</code> settings for the
+<code>server</code> scope denotes the minimum and maximum states to keep in a pool per
server <em>process</em>, so keep this below your <code>ThreadsPerChild</code> limit.
</p>
<h3>Using code caching</h3>
<p>
-By default, <code class="module"><a href="../mod/mod_lua.html">mod_lua</a></code> stats each Lua script to determine whether a reload
-(and thus, a re-interpretation and re-compilation) of a script is required. This is managed
-through the <code class="directive"><a href="../mod/mod_lua.html#luacodecache">LuaCodeCache</a></code> directive. If you are running
-your scripts on a production server, and you do not need to update them regularly, it may be
-advantageous to set this directive to the <code>forever</code> value, which will cause mod_lua
-to skip the stat process and always reuse the compiled byte-code from the first access to the
-script, thus speeding up the processing. For Lua hooks, this can prove to increase peformance,
-while for scripts handled by the <code>lua-script</code> handler, the increase in performance
+By default, <code class="module"><a href="../mod/mod_lua.html">mod_lua</a></code> stats each Lua script to determine whether a reload
+(and thus, a re-interpretation and re-compilation) of a script is required. This is managed
+through the <code class="directive"><a href="../mod/mod_lua.html#luacodecache">LuaCodeCache</a></code> directive. If you are running
+your scripts on a production server, and you do not need to update them regularly, it may be
+advantageous to set this directive to the <code>forever</code> value, which will cause mod_lua
+to skip the stat process and always reuse the compiled byte-code from the first access to the
+script, thus speeding up the processing. For Lua hooks, this can prove to increase peformance,
+while for scripts handled by the <code>lua-script</code> handler, the increase in performance
may be negligible, as files httpd will stat the files regardless.
</p>
<h3>Keeping the scope clean</h3>
<p>
-For maximum performance, it is generally recommended that any initialization of libraries,
+For maximum performance, it is generally recommended that any initialization of libraries,
constants and master tables be kept outside the handle's scope:
</p>
<pre class="prettyprint lang-lua">--[[ This is good practice ]]--
<div class="section">
<h2><a name="basic_remap" id="basic_remap">Example 1: A basic remapping module</a></h2>
<p>
- These first examples show how mod_lua can be used to rewrite URIs in the same
- way that one could do using <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> or
- <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>, but with more clarity
- on how the decision-making takes place, as well as allowing for more complex
+ These first examples show how mod_lua can be used to rewrite URIs in the same
+ way that one could do using <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> or
+ <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>, but with more clarity
+ on how the decision-making takes place, as well as allowing for more complex
decisions than would otherwise be allowed with said directives.
</p>
<pre class="prettyprint lang-lua">--[[
Advanced remap example.
- This example will evaluate some conditions, and based on that,
+ This example will evaluate some conditions, and based on that,
remap a file to one of two destinations, using a rewrite map.
- This is similar to mixing AliasMatch and ProxyPass, but
+ This is similar to mixing AliasMatch and ProxyPass, but
without them clashing in any way. Assuming we are on example.com, then:
http://example.com/photos/test.png will be rewritten as /uploads/www/test.png
]]--
local map = {
- photos = {
- source = [[^/photos/(.+)\.png$]],
+ photos = {
+ source = [[^/photos/(.+)\.png$]],
destination = [[/uploads/www/$1.png]],
proxy = false
},
function interpolateString(s,v)
return s:gsub("%$(%d+)", function(a) return v[tonumber(a)] end)
end
-
+
function remap(r)
-- browse through the rewrite map
for key, entry in pairs(map) do
<div class="section">
<h2><a name="mass_vhost" id="mass_vhost">Example 2: Mass virtual hosting</a></h2>
<p>
- As with simple and advanced rewriting, you can use mod_lua for dynamically
- assigning a hostname to a specific document root, much like
- <code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code> does, but with more control over what goes
- where. This could be as simple as a table holding the information about which
- host goes into which folder, or more advanced, using a database holding the
+ As with simple and advanced rewriting, you can use mod_lua for dynamically
+ assigning a hostname to a specific document root, much like
+ <code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code> does, but with more control over what goes
+ where. This could be as simple as a table holding the information about which
+ host goes into which folder, or more advanced, using a database holding the
document roots of each hostname.
</p>
<pre class="prettyprint lang-lua">--[[
Simple mass vhost script
- This example will check a map for a virtual host and rewrite filename and
+ This example will check a map for a virtual host and rewrite filename and
document root accordingly.
]]--
end
db:close()
end
- if cached_vhosts[host] then
+ if cached_vhosts[host] then
return cached_vhosts[host].destination
else
return nil
end
end
-
+
function mass_vhost(r)
-- Check whether the hostname is in our database
local destination = query_vhosts(r)
<div class="section">
<h2><a name="basic_auth" id="basic_auth">Example 3: A basic authorization hook</a></h2>
<p>
- With the authorization hooks, you can add custom auth phases to your request
- processing, allowing you to either add new requirements that were not previously
- supported by httpd, or tweaking existing ones to accommodate your needs.
+ With the authorization hooks, you can add custom auth phases to your request
+ processing, allowing you to either add new requirements that were not previously
+ supported by httpd, or tweaking existing ones to accommodate your needs.
</p>
<pre class="prettyprint lang-config">LuaHookAuthChecker /path/too/foo.lua check_auth</pre>
-<pre class="prettyprint lang-lua">--[[
+<pre class="prettyprint lang-lua">--[[
A simple authentication hook that checks a table containing usernames and
passwords of two accounts.
]]--
-<pre class="prettyprint lang-lua">--[[
+<pre class="prettyprint lang-lua">--[[
An advanced authentication checker with a database backend,
caching account entries for 1 minute
]]--
end
db:close()
end
- if accounts[user] then
+ if accounts[user] then
return accounts[user].password
else
return nil
end
end
-
+
-- The authentication hook
function check_auth(r)
local user, pass = parse_auth(r.headers_in['Authorization'])
<div class="section">
<h2><a name="authz" id="authz">Example 4: Authorization using LuaAuthzProvider</a></h2>
<p>
- If you require even more advanced control over your authorization phases,
- you can add custom authz providers to help you manage your server. The
- example below shows you how you can split a single htpasswd file into
+ If you require even more advanced control over your authorization phases,
+ you can add custom authz providers to help you manage your server. The
+ example below shows you how you can split a single htpasswd file into
groups with different permissions:
</p>
<pre class="prettyprint lang-config">LuaAuthzProvider rights /path/to/lua/script.lua rights_handler
</Directory></pre>
-<pre class="prettyprint lang-lua">--[[
- This script has two user groups; members and admins, and whichever
+<pre class="prettyprint lang-lua">--[[
+ This script has two user groups; members and admins, and whichever
is refered to by the "Require rights" directive is checked to see
if the authenticated user belongs to this group.
]]--
<div class="section">
<h2><a name="loadbalancing" id="loadbalancing">Example 5: A rudimentary load balancer</a></h2>
<p>
- This is an example of how you can create a load balancing mechanism.
- In this example, we will be setting/getting the number of requests served
- by each backend using IVM variables, and preferring the backend with least
+ This is an example of how you can create a load balancing mechanism.
+ In this example, we will be setting/getting the number of requests served
+ by each backend using IVM variables, and preferring the backend with least
requests served in total:
</p>
<pre class="prettyprint lang-config">LuaHookTranslateName /path/to/script.lua proxy_handler</pre>
-<pre class="prettyprint lang-lua">--[[
- This script uses a basic IVM table to determine where to
+<pre class="prettyprint lang-lua">--[[
+ This script uses a basic IVM table to determine where to
send the request.
]]--
</section>
<section id="contents"><title>What we will be discussing in this document</title>
<p>
-This document will discuss several cases where <module>mod_lua</module> can be used
-to either ease up a phase of the request processing or create more transparency in
+This document will discuss several cases where <module>mod_lua</module> can be used
+to either ease up a phase of the request processing or create more transparency in
the logic behind a decision made in a phase.
</p>
<section id="prerequisites"><title>Prerequisites</title>
<p>
-First and foremost, you are expected to have a basic knowledge of how the Lua
-programming language works. In most cases, we will try to be as pedagogical
-as possible and link to documents describing the functions used in the
-examples, but there are also many cases where it is necessary to either
-just assume that "it works" or do some digging yourself into what the hows
-and whys of various function calls.
+First and foremost, you are expected to have a basic knowledge of how the Lua
+programming language works. In most cases, we will try to be as pedagogical
+as possible and link to documents describing the functions used in the
+examples, but there are also many cases where it is necessary to either
+just assume that "it works" or do some digging yourself into what the hows
+and whys of various function calls.
</p>
<section><title>Setting a scope for Lua states</title>
<p>
-Setting the right <directive module="mod_lua">LuaScope</directive> setting
-for your Lua scripts can be essential to your server's
-performance. By default, the scope is set to <code>once</code>, which means
-that every call to a Lua script will spawn a new Lua state that handles that
-script and is destroyed immediately after. This option keeps the memory
-footprint of mod_lua low, but also affects the processing speed of a request.
-If you have the memory to spare, you can set the scope to <code>thread</code>,
-which will make mod_lua spawn a Lua state that lasts the entirity of a thread's
-lifetime, speeding up request processing by 2-3 times. Since mod_lua will create
-a state for each script, this may be an expensive move, memory-wise, so to
-compromise between speed and memory usage, you can choose the <code>server</code>
-option to create a pool of Lua states to be used. Each request for a Lua script or
-a hook function will then acquire a state from the pool and release it back when it's
-done using it, allowing you to still gain a significant performance increase, while
+Setting the right <directive module="mod_lua">LuaScope</directive> setting
+for your Lua scripts can be essential to your server's
+performance. By default, the scope is set to <code>once</code>, which means
+that every call to a Lua script will spawn a new Lua state that handles that
+script and is destroyed immediately after. This option keeps the memory
+footprint of mod_lua low, but also affects the processing speed of a request.
+If you have the memory to spare, you can set the scope to <code>thread</code>,
+which will make mod_lua spawn a Lua state that lasts the entirity of a thread's
+lifetime, speeding up request processing by 2-3 times. Since mod_lua will create
+a state for each script, this may be an expensive move, memory-wise, so to
+compromise between speed and memory usage, you can choose the <code>server</code>
+option to create a pool of Lua states to be used. Each request for a Lua script or
+a hook function will then acquire a state from the pool and release it back when it's
+done using it, allowing you to still gain a significant performance increase, while
keeping your memory footprint low. Some examples of possible settings are:
</p>
<highlight language="config">
LuaScope server 5 40
</highlight>
<p>
-As a general rule of thumb: If your server has none to low usage, use <code>once</code>
-or <code>request</code>, if your server has low to medium usage, use the <code>server</code>
-pool, and if it has high usage, use the <code>thread</code> setting. As your server's
-load increases, so will the number of states being actively used, and having your scope
+As a general rule of thumb: If your server has none to low usage, use <code>once</code>
+or <code>request</code>, if your server has low to medium usage, use the <code>server</code>
+pool, and if it has high usage, use the <code>thread</code> setting. As your server's
+load increases, so will the number of states being actively used, and having your scope
set to <code>once/request/conn</code> will stop being beneficial to your memory footprint.
</p>
<p>
-<strong>Note:</strong> The <code>min</code> and <code>max</code> settings for the
-<code>server</code> scope denotes the minimum and maximum states to keep in a pool per
+<strong>Note:</strong> The <code>min</code> and <code>max</code> settings for the
+<code>server</code> scope denotes the minimum and maximum states to keep in a pool per
server <em>process</em>, so keep this below your <code>ThreadsPerChild</code> limit.
</p>
</section>
<section><title>Using code caching</title>
<p>
-By default, <module>mod_lua</module> stats each Lua script to determine whether a reload
-(and thus, a re-interpretation and re-compilation) of a script is required. This is managed
-through the <directive module="mod_lua">LuaCodeCache</directive> directive. If you are running
-your scripts on a production server, and you do not need to update them regularly, it may be
-advantageous to set this directive to the <code>forever</code> value, which will cause mod_lua
-to skip the stat process and always reuse the compiled byte-code from the first access to the
-script, thus speeding up the processing. For Lua hooks, this can prove to increase peformance,
-while for scripts handled by the <code>lua-script</code> handler, the increase in performance
+By default, <module>mod_lua</module> stats each Lua script to determine whether a reload
+(and thus, a re-interpretation and re-compilation) of a script is required. This is managed
+through the <directive module="mod_lua">LuaCodeCache</directive> directive. If you are running
+your scripts on a production server, and you do not need to update them regularly, it may be
+advantageous to set this directive to the <code>forever</code> value, which will cause mod_lua
+to skip the stat process and always reuse the compiled byte-code from the first access to the
+script, thus speeding up the processing. For Lua hooks, this can prove to increase peformance,
+while for scripts handled by the <code>lua-script</code> handler, the increase in performance
may be negligible, as files httpd will stat the files regardless.
</p>
</section>
<section><title>Keeping the scope clean</title>
<p>
-For maximum performance, it is generally recommended that any initialization of libraries,
+For maximum performance, it is generally recommended that any initialization of libraries,
constants and master tables be kept outside the handle's scope:
</p>
<highlight language="lua">
<section id="basic_remap"><title>Example 1: A basic remapping module</title>
<p>
- These first examples show how mod_lua can be used to rewrite URIs in the same
- way that one could do using <directive module="mod_alias">Alias</directive> or
- <directive module="mod_rewrite">RewriteRule</directive>, but with more clarity
- on how the decision-making takes place, as well as allowing for more complex
+ These first examples show how mod_lua can be used to rewrite URIs in the same
+ way that one could do using <directive module="mod_alias">Alias</directive> or
+ <directive module="mod_rewrite">RewriteRule</directive>, but with more clarity
+ on how the decision-making takes place, as well as allowing for more complex
decisions than would otherwise be allowed with said directives.
</p>
<highlight language="lua">
--[[
Advanced remap example.
- This example will evaluate some conditions, and based on that,
+ This example will evaluate some conditions, and based on that,
remap a file to one of two destinations, using a rewrite map.
- This is similar to mixing AliasMatch and ProxyPass, but
+ This is similar to mixing AliasMatch and ProxyPass, but
without them clashing in any way. Assuming we are on example.com, then:
http://example.com/photos/test.png will be rewritten as /uploads/www/test.png
]]--
local map = {
- photos = {
- source = [[^/photos/(.+)\.png$]],
+ photos = {
+ source = [[^/photos/(.+)\.png$]],
destination = [[/uploads/www/$1.png]],
proxy = false
},
function interpolateString(s,v)
return s:gsub("%$(%d+)", function(a) return v[tonumber(a)] end)
end
-
+
function remap(r)
-- browse through the rewrite map
for key, entry in pairs(map) do
<section id="mass_vhost"><title>Example 2: Mass virtual hosting</title>
<p>
- As with simple and advanced rewriting, you can use mod_lua for dynamically
- assigning a hostname to a specific document root, much like
- <module>mod_vhost_alias</module> does, but with more control over what goes
- where. This could be as simple as a table holding the information about which
- host goes into which folder, or more advanced, using a database holding the
+ As with simple and advanced rewriting, you can use mod_lua for dynamically
+ assigning a hostname to a specific document root, much like
+ <module>mod_vhost_alias</module> does, but with more control over what goes
+ where. This could be as simple as a table holding the information about which
+ host goes into which folder, or more advanced, using a database holding the
document roots of each hostname.
</p>
<highlight language="lua">
--[[
Simple mass vhost script
- This example will check a map for a virtual host and rewrite filename and
+ This example will check a map for a virtual host and rewrite filename and
document root accordingly.
]]--
end
db:close()
end
- if cached_vhosts[host] then
+ if cached_vhosts[host] then
return cached_vhosts[host].destination
else
return nil
end
end
-
+
function mass_vhost(r)
-- Check whether the hostname is in our database
local destination = query_vhosts(r)
<section id="basic_auth"><title>Example 3: A basic authorization hook</title>
<p>
- With the authorization hooks, you can add custom auth phases to your request
- processing, allowing you to either add new requirements that were not previously
- supported by httpd, or tweaking existing ones to accommodate your needs.
+ With the authorization hooks, you can add custom auth phases to your request
+ processing, allowing you to either add new requirements that were not previously
+ supported by httpd, or tweaking existing ones to accommodate your needs.
</p>
<highlight language="config">
LuaHookAuthChecker /path/too/foo.lua check_auth
<!-- BEGIN EXAMPLE CODE -->
<highlight language="lua">
---[[
+--[[
A simple authentication hook that checks a table containing usernames and
passwords of two accounts.
]]--
<!-- BEGIN EXAMPLE CODE -->
<highlight language="lua">
---[[
+--[[
An advanced authentication checker with a database backend,
caching account entries for 1 minute
]]--
end
db:close()
end
- if accounts[user] then
+ if accounts[user] then
return accounts[user].password
else
return nil
end
end
-
+
-- The authentication hook
function check_auth(r)
local user, pass = parse_auth(r.headers_in['Authorization'])
<section id="authz"><title>Example 4: Authorization using LuaAuthzProvider</title>
<p>
- If you require even more advanced control over your authorization phases,
- you can add custom authz providers to help you manage your server. The
- example below shows you how you can split a single htpasswd file into
+ If you require even more advanced control over your authorization phases,
+ you can add custom authz providers to help you manage your server. The
+ example below shows you how you can split a single htpasswd file into
groups with different permissions:
</p>
<highlight language="config">
</highlight>
<highlight language="lua">
---[[
- This script has two user groups; members and admins, and whichever
+--[[
+ This script has two user groups; members and admins, and whichever
is refered to by the "Require rights" directive is checked to see
if the authenticated user belongs to this group.
]]--
<section id="loadbalancing"><title>Example 5: A rudimentary load balancer</title>
<p>
- This is an example of how you can create a load balancing mechanism.
- In this example, we will be setting/getting the number of requests served
- by each backend using IVM variables, and preferring the backend with least
+ This is an example of how you can create a load balancing mechanism.
+ In this example, we will be setting/getting the number of requests served
+ by each backend using IVM variables, and preferring the backend with least
requests served in total:
</p>
<highlight language="config">
</highlight>
<highlight language="lua">
---[[
- This script uses a basic IVM table to determine where to
+--[[
+ This script uses a basic IVM table to determine where to
send the request.
]]--
late during request processing meaning that directives such as
<code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code> and <code class="directive"><a href="./mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> will not see the
variables set with it.</li>
-
- <li>When the server looks up a path via an internal
- <a class="glossarylink" href="./glossary.html#subrequest" title="see glossary">subrequest</a> such as looking
- for a <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code>
+
+ <li>When the server looks up a path via an internal
+ <a class="glossarylink" href="./glossary.html#subrequest" title="see glossary">subrequest</a> such as looking
+ for a <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code>
or generating a directory listing with <code class="module"><a href="./mod/mod_autoindex.html">mod_autoindex</a></code>,
- per-request environment variables are <em>not</em> inherited in the
- subrequest. Additionally,
+ per-request environment variables are <em>not</em> inherited in the
+ subrequest. Additionally,
<code class="directive"><a href="./mod/mod_setenvif.html#setenvif">SetEnvIf</a></code> directives
are not separately evaluated in the subrequest due to the API phases
<code class="module"><a href="./mod/mod_setenvif.html">mod_setenvif</a></code> takes action in.</li>
</a></code> and <code class="module"><a href="./mod/mod_headers.html">mod_headers</a></code> allows you to still accept
these headers:</p>
-<pre class="prettyprint lang-config">#
+<pre class="prettyprint lang-config">#
# The following works around a client sending a broken Accept_Encoding
# header.
#
<directive module="mod_setenvif">SetEnvIf</directive> and <directive
module="mod_rewrite">RewriteCond</directive> will not see the
variables set with it.</li>
-
- <li>When the server looks up a path via an internal
- <glossary ref="subrequest">subrequest</glossary> such as looking
- for a <directive module="mod_dir" >DirectoryIndex</directive>
+
+ <li>When the server looks up a path via an internal
+ <glossary ref="subrequest">subrequest</glossary> such as looking
+ for a <directive module="mod_dir" >DirectoryIndex</directive>
or generating a directory listing with <module>mod_autoindex</module>,
- per-request environment variables are <em>not</em> inherited in the
- subrequest. Additionally,
+ per-request environment variables are <em>not</em> inherited in the
+ subrequest. Additionally,
<directive module="mod_setenvif">SetEnvIf</directive> directives
are not separately evaluated in the subrequest due to the API phases
<module>mod_setenvif</module> takes action in.</li>
these headers:</p>
<highlight language="config">
-#
+#
# The following works around a client sending a broken Accept_Encoding
# header.
#
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="examples" id="examples">Example expressions</a></h2>
-
+
<p>The following examples show how expressions might be used to
evaluate requests:</p>
# Only allow access to this content during business hours
<Directory "/foo/bar/business">
Require expr %{TIME_HOUR} -gt 9 && %{TIME_HOUR} -lt 17
-</Directory>
+</Directory>
# Check a HTTP header for a list of values
<If "%{HTTP:X-example-header} in { 'foo', 'bar', 'baz' }">
</section>
<section id="examples">
-
+
<title>Example expressions</title>
<p>The following examples show how expressions might be used to
evaluate requests:</p>
# Only allow access to this content during business hours
<Directory "/foo/bar/business">
Require expr %{TIME_HOUR} -gt 9 && %{TIME_HOUR} -lt 17
-</Directory>
+</Directory>
# Check a HTTP header for a list of values
<If "%{HTTP:X-example-header} in { 'foo', 'bar', 'baz' }">
as to not invade the media type name-space.</p>
</section>
</manualpage>
-
-
-
-
-
syntax.</p>
<p>You can insert <code>not</code> to negate a particular requirement.
- Note, that since a <code>not</code> is a negation of a value, it cannot
+ Note, that since a <code>not</code> is a negation of a value, it cannot
be used by itself to allow or deny a request, as <em>not true</em>
does not constitute <em>false</em>. Thus, to deny a visit using a negation,
the block must have one element that evaluates as true or false.
<p>Visitors coming from that address (<code>10.252.46.165</code>)
- will not be able to see the content covered by this directive. If,
- instead, you have a machine name, rather than an IP address, you
+ will not be able to see the content covered by this directive. If,
+ instead, you have a machine name, rather than an IP address, you
can use that.</p>
- <pre class="prettyprint lang-config">Require not host <var>host.example.com</var></pre>
+ <pre class="prettyprint lang-config">Require not host <var>host.example.com</var>
+ </pre>
<p>And, if you'd like to block access from an entire domain,
and 6am, you can do this using <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
<pre class="prettyprint lang-config">RewriteEngine On
-RewriteCond %{TIME_HOUR} >=20 [OR]
-RewriteCond %{TIME_HOUR} <07
-RewriteRule ^/fridge - [F]</pre>
+RewriteCond "%{TIME_HOUR}" ">=20" [OR]
+RewriteCond "%{TIME_HOUR}" "<07"
+RewriteRule "^/fridge" "-" [F]</pre>
<p>This will return a 403 Forbidden response for any request after 8pm
<p><span>Langues Disponibles: </span><a href="../en/howto/access.html" hreflang="en" rel="alternate" title="English"> en </a> |
<a href="../fr/howto/access.html" title="Français"> fr </a></p>
</div>
+<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
+ anglaise pour les changements récents.</div>
<p>Le contrôle d'accès fait référence à tout concept de contrôle
d'accès à une ressource quelconque. Il est distinct du processus d'<a href="auth.html">authentification et d'autorisation</a>.</p>
<highlight language="config">
RewriteEngine On
-RewriteCond %{TIME_HOUR} >=20 [OR]
-RewriteCond %{TIME_HOUR} <07
-RewriteRule ^/fridge - [F]
+RewriteCond "%{TIME_HOUR}" ">=20" [OR]
+RewriteCond "%{TIME_HOUR}" "<07"
+RewriteRule "^/fridge" "-" [F]
</highlight>
<p>This will return a 403 Forbidden response for any request after 8pm
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
-<!-- English Revision : 1666025 -->
+<!-- English Revision: 1666025:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<variants>
<variant>en</variant>
- <variant>fr</variant>
+ <variant outdated="yes">fr</variant>
</variants>
</metafile>
that will be called during the authorization stage of the request
processing. For example:</p>
- <pre class="prettyprint lang-config">Require ip <var>address</var></pre>
+ <pre class="prettyprint lang-config">Require ip <var>address</var>
+ </pre>
<p>where <var>address</var> is an IP address (or a partial IP
address) or:</p>
- <pre class="prettyprint lang-config">Require host <var>domain_name</var></pre>
+ <pre class="prettyprint lang-config">Require host <var>domain_name</var>
+ </pre>
<p>where <var>domain_name</var> is a fully qualified domain name
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1599841:1673582 (outdated) -->
+<!-- English Revision: 1599841:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviwed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 479777:1673582 (outdated) -->
+<!-- English Revision: 479777:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='EUC-KR' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 105989:1673582 (outdated) -->
+<!-- English Revision: 105989:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1070891:1673582 (outdated) -->
+<!-- English Revision: 1070891:1673932 (outdated) -->
<!-- =====================================================
Translated by: Umut Samuk <umut belgeler.org>
Reviewed by: Nilgün Belma Bugüner <nilgun belgeler.org>
have found a problem in the Apache source code.</p>
</section>
</manualpage>
-
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1649338:1673892 (outdated) -->
+<!-- English Revision: 1649338:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1591191:1673892 (outdated) -->
+<!-- English Revision: 1591191:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='EUC-KR' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1673892 (outdated) -->
+<!-- English Revision: 151408:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1174747:1673892 (outdated) -->
+<!-- English Revision: 1174747:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
<p><span>Available Languages: </span><a href="../en/misc/perf-scaling.html" title="English"> en </a></p>
</div>
-
- <p>The Performance Tuning page in the Apache 1.3 documentation says:
+
+ <p>The Performance Tuning page in the Apache 1.3 documentation says:
</p>
<blockquote><p>
"Apache is a general webserver, which is designed to be
The classic brochureware site is alive and well, but the web has
grown up substantially as a computing application platform and
webmasters may find themselves running dynamic content in Perl, PHP
- or Java, all of which take a toll on performance.
+ or Java, all of which take a toll on performance.
</p>
<p>Therefore, in spite of strides forward in machine speed and
bandwidth allowances, web server performance and web application
performance remain areas of concern. In this documentation several
- aspects of web server performance will be discussed.
+ aspects of web server performance will be discussed.
</p>
-
+
</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#what-will-and-will-not-be-discussed">What Will and Will Not Be Discussed
</a></li>
server hardware, so the existing infrastructure will have to do the
job. You have no desire to compile your own Apache, or to recompile
the operating system kernel. We do assume, though, that you have
- some familiarity with the Apache httpd configuration file.
+ some familiarity with the Apache httpd configuration file.
</p>
-
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="monitoring-your-server" id="monitoring-your-server">Monitoring Your Server
find out how your system is currently performing. By monitoring
your server under real-world load, or artificially generated load,
you can extrapolate its behavior under stress, such as when your
- site is mentioned on Slashdot.
+ site is mentioned on Slashdot.
</p>
-
-
+
+
<h3><a name="monitoring-tools" id="monitoring-tools">Monitoring Tools
</a></h3>
-
-
+
+
<h4><a name="top" id="top">top
</a></h4>
ID, priority and nice values, memory footprint, and
percentage CPU usage. The following example shows multiple
httpd processes (with MPM worker and event) running on an
- Linux (Xen) system:
+ Linux (Xen) system:
</p>
-
+
<div class="example"><pre>top - 23:10:58 up 71 days, 6:14, 4 users, load average: 0.25, 0.53, 0.47
Tasks: 163 total, 1 running, 162 sleeping, 0 stopped, 0 zombie
Cpu(s): 11.6%us, 0.7%sy, 0.0%ni, 87.3%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
68 root 15 -5 0 0 0 S 0 0.0 0:06.28 kblockd/0
69 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/1
70 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/2</pre></div>
-
+
<p>Top is a wonderful tool even though it's slightly resource
intensive (when running, its own process is usually in the
top ten CPU gluttons). It is indispensable in determining
determining how many server processes you can run on your
machine. How to do this is described in <a href="#sizing-maxClients">sizing MaxClients</a>.
Top is, however, an interactive tool and running it
- continuously has few if any advantages.
+ continuously has few if any advantages.
</p>
<h4><a name="free" id="free">free
both with and without this cache. The free command can be
used to find out how much memory the operating system is
using, as described in the paragraph <a href="#sizing-maxClients">sizing MaxClients</a>.
- The output of free looks like this:
+ The output of free looks like this:
</p>
-
+
<div class="example"><pre>sctemme@brutus:~$ free
total used free shared buffers cached
Mem: 4026028 3901892 124136 0 253144 841044
-/+ buffers/cache: 2807704 1218324
Swap: 3903784 12540 3891244</pre></div>
-
+
<h4><a name="vmstat" id="vmstat">vmstat
</a></h4>
much memory is swapped in and out each second, the number
of processes currently running and sleeping, the number of
interrupts and context switches per second and the usage
- percentages of the CPU.
+ percentages of the CPU.
</p>
<p>
- The following is <code>vmstat</code> output of an idle server:
+ The following is <code>vmstat</code> output of an idle server:
</p>
-
-
+
+
<div class="example"><pre>[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
0 0 0 0 186252 6688 37516 0 0 12 5 47 311 0 1 99
0 0 0 0 186244 6696 37516 0 0 0 16 41 314 0 0 100
0 0 0 0 186236 6704 37516 0 0 0 9 44 314 0 0 100</pre></div>
-
+
<p>And this is output of a server that is under a load of one
- hundred simultaneous connections fetching static content:
+ hundred simultaneous connections fetching static content:
</p>
-
+
<div class="example"><pre>[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
1 0 1 0 162580 6848 40056 0 0 11 5 150 324 1 1 98
6 0 1 0 163280 6856 40248 0 0 0 66 6384 1117 42 25 32
11 0 0 0 162780 6864 40436 0 0 0 61 6309 1165 33 28 40</pre></div>
-
+
<p>The first line gives averages since the last reboot. The
subsequent lines give information for five second
intervals. The second argument tells vmstat to generate
- three reports and then exit.
+ three reports and then exit.
</p>
-
-
+
+
<h4><a name="se-toolkit" id="se-toolkit">SE Toolkit
</a></h4>
orange or red indicators when utilization of various parts
of the system rises above certain thresholds. Another
included script, Virtual Adrian, applies performance tuning
- metrics according to.
+ metrics according to.
</p>
<p>The SE Toolkit has drifted around for a while and has had
several owners since its inception. It seems that it has
code. SE Toolkit author Richard Pettit has started a new
company, Captive Metrics4 that plans to bring to market a
multiplatform monitoring tool built on the same principles
- as SE Toolkit, written in Java.
+ as SE Toolkit, written in Java.
</p>
-
-
+
+
<h4><a name="dtrace" id="dtrace">DTrace
</a></h4>
<p>Given that DTrace is available for Solaris, FreeBSD and OS
X, it might be worth exploring it. There's also
- mod_dtrace available for httpd.
+ mod_dtrace available for httpd.
</p>
-
-
+
+
<h4><a name="mod_status" id="mod_status">mod_status
</a></h4>
directive in your <code>httpd.conf</code>,
the <code class="module"><a href="../mod/mod_status.html">mod_status</a></code>
page will give you more information at the cost of a little
- extra work per request.
+ extra work per request.
</p>
-
-
+
+
<h3><a name="web-server-log-files" id="web-server-log-files">Web Server Log Files
from. Historical log file data can give you invaluable insight
into trends in access to your server, which allows you to
predict when your performance needs will overtake your server
- capacity.
+ capacity.
</p>
-
-
+
+
<h4><a name="ErrorLog" id="ErrorLog">Error Log
</a></h4>
redirected to the error logfile, so any error encountered
by httpd after it opens its logfiles will appear in this
log. This makes it good practice to review the error log
- frequently.
+ frequently.
</p>
<p>Before Apache httpd opens its logfiles, any errors will be
written to the stderr stream. If you start httpd manually,
file is usually a good bet. On Windows, early error
messages are written to the Applications Event Log, which
can be viewed through the Event Viewer in Administrative
- Tools.
+ Tools.
</p>
<p>
The Error Log is configured through the <code class="directive"><a href="../mod/core.html#errorlog">ErrorLog</a></code>
directive can also be used in virtual host containers. The
error log of a virtual host receives only log messages
specific to that virtual host, such as authentication
- failures and 'File not Found' errors.
+ failures and 'File not Found' errors.
</p>
<p>On a server that is visible to the Internet, expect to see a
lot of exploit attempt and worm attacks in the error log. A
port, regardless of which server is actually running or
what applications might be installed. You could block these
attempts using a firewall or <a href="http://www.modsecurity.org/">mod_security</a>,
- but this falls outside the scope of this discussion.
+ but this falls outside the scope of this discussion.
</p>
<p>
The <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
directive determines the level of detail included in the
- logs. There are eight log levels as described here:
+ logs. There are eight log levels as described here:
</p>
<table>
<tr>
not be run on debug, but increasing the level of detail in
the error log can be useful during troubleshooting.
Starting with 2.3.8 <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
- can be specified on a per module basis:
+ can be specified on a per module basis:
</p>
-
+
<pre class="prettyprint lang-config">LogLevel debug mod_ssl:warn</pre>
-
+
<p>
This puts all of the server in debug mode, except for
- <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>, which tends to be very noisy.
+ <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>, which tends to be very noisy.
</p>
-
-
+
+
<h4><a name="AccessLog" id="AccessLog">Access Log
</a></h4>
manual. This file exists by default for the main server and can be
configured per virtual host by using the <code class="directive"><a href="../mod/mod_log_config.html#transferlog">TransferLog</a></code>
or <code class="directive"><a href="../mod/mod_log_config.html#customlog">CustomLog</a></code>
- configuration directive.
+ configuration directive.
</p>
<p>The access logs can be analyzed with any of several free and
commercially available programs. Popular free analysis
be done offline so the web server machine is not burdened
by processing the log files. Most log analysis packages
understand the Common Log Format. The fields in the log
- lines are explained in in the following:
+ lines are explained in in the following:
</p>
-
-
+
+
<div class="example"><pre>195.54.228.42 - - [24/Mar/2007:23:05:11 -0400] "GET /sander/feed/ HTTP/1.1" 200 9747
64.34.165.214 - - [24/Mar/2007:23:10:11 -0400] "GET /sander/feed/atom HTTP/1.1" 200 9068
60.28.164.72 - - [24/Mar/2007:23:11:41 -0400] "GET / HTTP/1.0" 200 618
85.140.155.56 - - [24/Mar/2007:23:14:15 -0400] "GET /sander/2006/09/21/gore-tax-pollution/ HTTP/1.1" 200 15147
74.6.72.187 - - [24/Mar/2007:23:18:11 -0400] "GET /sander/2006/09/27/44/ HTTP/1.0" 200 14172
74.6.72.229 - - [24/Mar/2007:23:24:22 -0400] "GET /sander/2006/11/21/os-java/ HTTP/1.0" 200 13457</pre></div>
-
+
<table>
<tr>
<td>
</td>
</tr>
</table>
-
+
<h4><a name="rotating-log-files" id="rotating-log-files">Rotating Log Files
</a></h4>
file analysis should not be performed on files to which the
server is actively writing. Periodic logfile rotation helps
keep the analysis job manageable, and allows you to keep a
- closer eye on usage trends.
+ closer eye on usage trends.
</p>
<p>On unix systems, you can simply rotate logfiles by giving
the old file a new name using mv. The server will keep
writing to the open file even though it has a new name.
When you send a graceful restart signal to the server, it
will open a new logfile with the configured name. For
- example, you could run a script from cron like this:
+ example, you could run a script from cron like this:
</p>
-
-
+
+
<div class="example"><p><code>
APACHE=/usr/local/apache2<br />
HTTPD=$APACHE/bin/httpd<br />
$APACHE/logarchive/access_log-`date +%F`<br />
$HTTPD -k graceful
</code></p></div>
-
+
<p>This approach also works on Windows, just not as smoothly.
While the httpd process on your Windows server will keep
writing to the log file after it has been renamed, the
Windows Service has to perform will interrupt any requests
currently in progress, and the server is unavailable until
it is started again. Plan for this when you decide the
- timing of your restarts.
+ timing of your restarts.
</p>
<p>
A second approach is to use piped logs. From the
or <code class="directive"><a href="../mod/core.html#errorlog">ErrorLog
</a></code>
directives you can send the log data into any program using
- a pipe character (<code>|</code>). For instance:
+ a pipe character (<code>|</code>). For instance:
</p>
-
+
<div class="example"><p><code>CustomLog "|/usr/local/apache2/bin/rotatelogs
/var/log/access_log 86400" common
</code></p></div>
-
+
<p>The program on the other end of the pipe will receive the
Apache log data on its stdin stream, and can do with this
data whatever it wants. The rotatelogs program that comes
time elapsed or the amount of data written, and leaves the
old log files with a timestamp suffix to its name. This
method for rotating logfiles works well on unix platforms,
- but is currently broken on Windows.
+ but is currently broken on Windows.
</p>
-
-
+
+
<h4><a name="logging-and-performance" id="logging-and-performance">Logging and Performance
</a></h4>
the server log files: the access patterns are very
different. Retrieving content from disk is a read operation
in a fairly random pattern, and log files are written to
- disk sequentially.
+ disk sequentially.
</p>
<p>
Do not run a production server with your error <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code>
information to be written to the error log, including, in
the case of SSL access, complete dumps of BIO read and
write operations. The performance implications are
- significant: use the default warn level instead.
+ significant: use the default warn level instead.
</p>
<p>If your server has more than one virtual host, you may give
each virtual host a separate access logfile. This makes it
directive to have Apache collect several log lines in
memory before writing them to disk. This might yield better
performance, but could affect the order in which the
- server's log is written.
+ server's log is written.
</p>
-
-
+
+
<h3><a name="generating-a-test-load" id="generating-a-test-load">Generating A Test Load
performance under realistic operating circumstances. Besides
commercial packages such as <a href="http://learnloadrunner.com/">LoadRunner</a>
,there are a number of freely available tools to generate a
- test load against your web server.
+ test load against your web server.
</p>
<ul>
<li>Apache ships with a test program called ab, short for
repeatedly asking for the same file in rapid succession.
You can specify a number of concurrent connections and have
the program run for either a given amount of time or a
- specified number of requests.
+ specified number of requests.
</li>
<li>Another freely available load generator is http load11 .
This program works with a URL file and can be compiled with
- SSL support.
+ SSL support.
</li>
<li>The Apache Software Foundation offers a tool named flood12
. Flood is a fairly sophisticated program that is
- configured through an XML file.
+ configured through an XML file.
</li>
<li>Finally, JMeter13 , a Jakarta subproject, is an all-Java
load-testing tool. While early versions of this application
were slow and difficult to use, the current version 2.1.1
- seems to be versatile and useful.
+ seems to be versatile and useful.
</li>
<li>
<p>ASF external projects, that have proven to be quite
affect the server's response. Also, any data traffic you
generate may be charged against your monthly traffic allowance.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="configuring-for-performance" id="configuring-for-performance">Configuring for Performance
</a></h2>
-
-
+
+
<h3><a name="apache-configuration" id="apache-configuration">Httpd Configuration
</a></h3>
multiple request handling threads within each child process. In
2.4 MPMs are no longer hard-wired. They too can be exchanged
via <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code>.
- The default MPM in 2.4 is the event MPM.
+ The default MPM in 2.4 is the event MPM.
</p>
<p>The maximum number of workers, be they pre-forked child
processes or threads within a process, is an indication of how
the maximum number of workers is running, the machine
doesn't hit a hard limit beyond which clients will be
denied access. However, once requests start backing up, system
- performance is likely to degrade.
+ performance is likely to degrade.
</p>
<p>Finally, if the httpd server in question is not executing any third-party
code, via <code>mod_php</code>, <code>mod_perl</code> or similar,
for situations where httpd serves as a thin layer between clients and
backend servers doing the real job, such as a proxy or cache.
</p>
-
-
+
+
<h4><a name="MaxClients" id="MaxClients">MaxClients
</a></h4>
number of processes is configurable through the <code>
ServerLimit
</code>
- directive.
+ directive.
</p>
-
-
+
+
<h4><a name="spinning-threads" id="spinning-threads">Spinning Threads
</a></h4>
value downwards until it is an even factor of
<code>MaxClients</code>.
</p>
-
-
+
+
<h4><a name="sizing-maxClients" id="sizing-maxClients">Sizing MaxClients
</a></h4>
your system gets so overloaded that it needs to heavily
swap core memory out to disk, performance will degrade
quickly. The formula for determining <code class="directive"><a href="../mod/mpm_common.html#maxrequestworkers">MaxClients</a></code>
- is fairly simple:
+ is fairly simple:
</p>
-
+
<div class="example"><p><code>
total RAM - RAM for OS - RAM for external programs<br />
MaxClients =
-------------------------------------------------------<br />
RAM per httpd process
</code></p></div>
-
+
<p>The various amounts of memory allocated for the OS, external
programs and the httpd processes is best determined by
observation: use the top and free commands described above
server running. You can also determine the footprint of a
typical web server process from top: most top
implementations have a Resident Size (RSS) column and a
- Shared Memory column.
+ Shared Memory column.
</p>
<p>The difference between these two is the amount of memory
per-process. The shared segment really exists only once and
depends heavily on the number and kind of modules you use.
The best approach to use in determining this need is to
generate a typical test load against your web site and see
- how large the httpd processes become.
+ how large the httpd processes become.
</p>
<p>The RAM for external programs parameter is intended mostly
for CGI programs and scripts that run outside the web
to fork additional child processes, so a higher <code>
MaxClients
</code>
- value may actually be a disadvantage.
+ value may actually be a disadvantage.
</p>
-
-
+
+
<h4><a name="selecting-your-mpm" id="selecting-your-mpm">Selecting your MPM
</a></h4>
sense. On Linux, the threading implementation actually uses
one process for each thread. Linux processes are relatively
lightweight, but it means that a threaded MPM offers less
- of a performance advantage than in other environments.
+ of a performance advantage than in other environments.
</p>
<p>Running a threaded MPM can cause stability problems in some
situations For instance, should a child process of a
cannot guarantee that all of these are thread-safe. The
good news is that if you are running Apache on Linux, you
can run PHP in the preforked MPM without fear of losing too
- much performance relative to the threaded option.
+ much performance relative to the threaded option.
</p>
-
-
+
+
<h4><a name="spinning-locks" id="spinning-locks">Spinning Locks
</a></h4>
this time, the parent process may decide to terminate some
children based on its <code>MaxSpareServers
</code>
- directive.
+ directive.
</p>
-
-
+
+
<h4><a name="the-thundering-herd" id="the-thundering-herd">The Thundering Herd
</a></h4>
<p>The function of the 'accept mutex' (as this
inter-process lock is called) is to keep request reception
moving along in an orderly fashion. If the lock is absent,
- the server may exhibit the Thundering Herd syndrome.
+ the server may exhibit the Thundering Herd syndrome.
</p>
<p>Consider an American Football team poised on the line of
scrimmage. If the football players were Apache processes
would have to lumber back to the line for the next snap. In
this metaphor, the accept mutex acts as the quarterback,
delivering the connection "ball" to the
- appropriate player process.
+ appropriate player process.
</p>
<p>Moving this much information around is obviously a lot of
work, and, like a smart person, a smart web server tries to
refrain from using an accept mutex. If you run with
multiple listeners (for instance because you have a virtual
host serving SSL requests), it will activate the accept
- mutex to avoid internal conflicts.
+ mutex to avoid internal conflicts.
</p>
<p>
You can manipulate the accept mutex with the <code>
all are available on every platform, and their availability
also depends on compile-time settings. The various locking
mechanisms may place specific demands on system resources:
- manipulate them with care.
+ manipulate them with care.
</p>
<p>There is no compelling reason to disable the accept mutex.
Apache automatically recognizes the single listener
situation described above and knows if it is safe to run
- without mutex on your platform.
+ without mutex on your platform.
</p>
-
-
+
+
<h3><a name="tuning-the-operating-system" id="tuning-the-operating-system">Tuning the Operating System
are pretty well adjusted straight out of the box and there is
not a lot that needs to be done to make them perform optimally.
However, there are a few things that an administrator can do to
- improve performance.
+ improve performance.
</p>
-
-
+
+
<h4><a name="ram-and-swap-space" id="ram-and-swap-space">RAM and Swap Space
</a></h4>
virtual hosts-also tends to inflate the process footprint.
Having ample RAM allows you to run Apache with more child
processes, which allows the server to process more
- concurrent requests.
+ concurrent requests.
</p>
<p>While the various platforms treat their virtual memory in
different ways, it is never a good idea to run with less
don't have disk space available and run out of
swappable memory, your machine grinds to a halt. This can
crash your box, requiring a physical reboot for which your
- hosting facility may charge you.
+ hosting facility may charge you.
</p>
<p>Also, such an outage naturally occurs when you least want
it: when the world has found your website and is beating a
and back, but when the load decreases the system should
recover. Remember, you still have <code>MaxClients
</code>
- to keep things in hand.
+ to keep things in hand.
</p>
<p>Most unix-like operating systems use designated disk
partitions for swap space. When a system starts up it finds
installing the operating system, be sure to allocate enough
swap space to accommodate eventual RAM upgrades.
Reassigning disk space on a running system is a cumbersome
- process.
+ process.
</p>
<p>Plan for available hard drive swap space of at least twice
your amount of RAM, perhaps up to four times in situations
</code>
or <code>swap
</code>
- programs.
+ programs.
</p>
-
-
+
+
<h4><a name="ulimit-files-and-processes" id="ulimit-files-and-processes">ulimit: Files and Processes
</a></h4>
<p>Given a machine with plenty of RAM and processor capacity,
you can run hundreds of Apache processes if necessary. . .
- and if your kernel allows it.
+ and if your kernel allows it.
</p>
<p>Consider a situation in which several hundred web servers
are running; if some of these need to spawn CGI processes,
- the maximum number of processes would occur quickly.
+ the maximum number of processes would occur quickly.
</p>
- <p>However, you can change this limit with the command
+ <p>However, you can change this limit with the command
</p>
-
+
<div class="example"><p><code>
ulimit [-H|-S] -u [newvalue]
</code></p></div>
-
+
<p>This must be changed before starting the server, since the
new value will only be available to the current shell and
programs started from it. In newer Linux kernels the
</code>
:
</p>
-
+
<div class="example"><p><code>
limit [-h] maxproc [newvalue]
</code></p></div>
-
+
<p>Similarly, the kernel may limit the number of open files per
process. This is generally not a problem for pre-forked
servers, which just handle one request at a time per
process. Threaded servers, however, serve many requests per
process and much more easily run out of available file
descriptors. You can increase the maximum number of open
- files per process by running the
+ files per process by running the
</p>
-
+
<div class="example"><p><code>ulimit -n [newvalue]
</code></p></div>
-
+
<p>command. Once again, this must be done prior to starting
- Apache.
+ Apache.
</p>
-
-
+
+
<h4><a name="setting-user-limits-on-system-startup" id="setting-user-limits-on-system-startup">Setting User Limits on System Startup
</a></h4>
explaining the options. To enable this, make sure that the
file <code>/etc/pam.d/login
</code>
- contains the line
+ contains the line
</p>
-
+
<div class="example"><p><code>session required /lib/security/pam_limits.so
</code></p></div>
-
+
<p>All items can have a 'soft' and a 'hard'
limit: the first is the default setting and the second the
- maximum value for that item.
+ maximum value for that item.
</p>
<p>
In FreeBSD's <code>/etc/login.conf
boot time. These are the same tunables that can be set with
the <code>mdb</code>
kernel debugger during run time. The soft and hard limit
- corresponding to ulimit -u can be set via:
+ corresponding to ulimit -u can be set via:
</p>
-
+
<div class="example"><p><code>
set rlim_fd_max=65536<br />
set rlim_fd_cur=2048
</code></p></div>
-
+
<p>Solaris calculates the maximum number of allowed processes
per user (<code>maxuprc</code>) based on the total amount
available memory on the system (<code>maxusers</code>).
- You can review the numbers with
+ You can review the numbers with
</p>
-
+
<div class="example"><p><code>sysdef -i | grep maximum
</code></p></div>
-
- <p>but it is not recommended to change them.
+
+ <p>but it is not recommended to change them.
</p>
-
-
+
+
<h4><a name="turn-off-unused-services-and-modules" id="turn-off-unused-services-and-modules">Turn Off Unused Services and Modules
</a></h4>
services turned on by default. You probably need few of
them. For example, your web server does not need to be
running sendmail, nor is it likely to be an NFS server,
- etc. Turn them off.
+ etc. Turn them off.
</p>
<p>On Red Hat Linux, the chkconfig tool will help you do this
from the command line. On Solaris systems <code>svcs</code>
and <code>svcadm</code>
will show which services are enabled and disable them
- respectively.
+ respectively.
</p>
<p>In a similar fashion, cast a critical eye on the Apache
modules you load. Most binary distributions of Apache
httpd, and pre-installed versions that come with Linux
distributions, have their modules enabled through the
- <code class="directive">LoadModule</code> directive.
+ <code class="directive">LoadModule</code> directive.
</p>
<p>Unused modules may be culled: if you don't rely on
their functionality and configuration directives, you can
lines. Read the documentation on each module's
functionality before deciding whether to keep it enabled.
While the performance overhead of an unused module is
- small, it's also unnecessary.
+ small, it's also unnecessary.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
Static content consists of simple filespages, images, etc.-on disk
that are very efficiently served. Many operating systems also
automatically cache the contents of frequently accessed files in
- memory.
+ memory.
</p>
<p>Processing dynamic requests, on the contrary, can be much more
involved. Running CGI scripts, handing off requests to an external
significant latency and processing load to a busy web server. Under
many circumstances, performance can be improved by turning popular
dynamic requests into static requests. In this section, two
- approaches to this will be discussed.
+ approaches to this will be discussed.
</p>
-
-
+
+
<h3><a name="making-popular-pages-static" id="making-popular-pages-static">Making Popular Pages Static
</a></h3>
they are served the pre-rendered page. Queries for, say, yellow
roses will be generated directly from the database. The
mod_rewrite module included with Apache is a great tool to
- implement these substitutions.
+ implement these substitutions.
</p>
-
-
+
+
<h4><a name="example-a-statically-rendered-blog" id="example-a-statically-rendered-blog">Example: A Statically Rendered Blog
</a></h4>
-
+
<p>Blosxom is a lightweight web log package that runs as a CGI.
It is written in Perl and uses plain text files for entry
input. Besides running as CGI, Blosxom can be run from the
command line to pre-render blog pages. Pre-rendering pages
to static HTML can yield a significant performance boost in
the event that large numbers of people actually start
- reading your blog.
+ reading your blog.
</p>
<p>To run blosxom for static page generation, edit the CGI
script according to the documentation. Set the $static dir
variable to the <code class="directive">DocumentRoot</code>
of the web server, and run the script from the command line
- as follows:
+ as follows:
</p>
-
+
<div class="example"><p><code>$ perl blosxom.cgi -password='whateveryourpassword'
</code></p></div>
-
+
<p>This can be run periodically from Cron, after you upload
content, etc. To make Apache substitute the statically
rendered pages for the dynamic content, we'll use
to the configure command. Many binary distributions of
Apache come with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite </a></code> included. The following is an
example of an Apache virtual host that takes advantage of
- pre-rendered blog pages:
+ pre-rendered blog pages:
</p>
-
+
<pre class="prettyprint lang-config">Listen *:8001
<VirtualHost *:8001>
ServerName blog.sandla.org:8001
Options +Indexes
Require all granted
RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA]
+ RewriteCond "%{REQUEST_FILENAME}" "!-f"
+ RewriteCond "%{REQUEST_FILENAME}" "!-d"
+ RewriteRule "^(.*)$" "/cgi-bin/blosxom.cgi/$1" [L,QSA]
</Directory>
- RewriteLog /home/sctemme/inst/blog/httpd/logs/rewrite_log
+ RewriteLog "/home/sctemme/inst/blog/httpd/logs/rewrite_log"
RewriteLogLevel 9
ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
LogLevel debug
</Directory>
</VirtualHost></pre>
-
+
<p>
The <code class="directive">RewriteCond</code>
and <code class="directive">RewriteRule</code>
hides the Blosxom CGI from the user-visible URL in their
Location bar. mod_rewrite is a fantastically powerful and
versatile module: investigate it to arrive at a
- configuration that is best for your situation.
+ configuration that is best for your situation.
</p>
-
-
+
+
<h3><a name="caching-content-with-mod_cache" id="caching-content-with-mod_cache">Caching Content With mod_cache
server systems will have more disk available than memory, and
it's good to note that some operating system kernels cache
frequently accessed disk content transparently in memory, so
- replicating this in the server is not very useful.
+ replicating this in the server is not very useful.
</p>
<p>To enable efficient content caching and avoid presenting the
user with stale or invalid content, the application that
generates the actual content has to send the correct response
- headers. Without headers like <code>Etag:</code>,
+ headers. Without headers like <code>Etag:</code>,
<code>Last-Modified:</code> or <code>Expires:</code>,
<code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> can not make the right decision on whether to cache
the content, serve it from cache or leave it alone. When
option <code>--enable-cache[=shared]</code>
to the configure script. If you use a binary distribution of
Apache httpd, or it came with your port or package collection,
- it may have <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> already included.
+ it may have <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> already included.
</p>
-
-
+
+
<h4><a name="example-wiki" id="example-wiki">Example: wiki.apache.org
</a></h4>
enabled with the following configuration snippet in
<code>httpd.conf</code>:
</p>
-
+
<pre class="prettyprint lang-config">CacheRoot /raid1/cacheroot
CacheEnable disk /
# A page modified 100 minutes ago will expire in 10 minutes
# Always check again after 6 hours
CacheMaxExpire 21600</pre>
-
+
<p>This configuration will try to cache any and all content
within its virtual host. It will never cache content for
more than six hours (the <code class="directive"><a href="../mod/mod_cache.html#cachemaxexpire">CacheMaxExpire</a></code>
header. The computation using <code class="directive"><a href="../mod/mod_cache.html#cachelastmodifiedfactor">CacheLastModifiedFactor</a></code>
is based on the assumption that if a page was recently
modified, it is likely to change again in the near future
- and will have to be re-cached.
+ and will have to be re-cached.
</p>
<p>
Do note that it can pay off to <em>disable</em>
TCP packet). For resources larger than 1k it might prove
CPU expensive to calculate the header for each request.
Unfortunately there does currently not exist a way to cache
- these headers.
+ these headers.
</p>
<pre class="prettyprint lang-config"><FilesMatch "\.(jpe?g|png|gif|js|css|x?html|xml)">
FileETag None
</FilesMatch></pre>
-
+
<p>
This will disable the generation of the <code>ETag:</code>
header for most static resources. The server does not
- calculate these headers for dynamic resources.
+ calculate these headers for dynamic resources.
</p>
-
-
+
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
See the License for the specific language governing permissions and
limitations under the License.
-->
-<manualpage metafile="perf-scaling.xml.meta">
+<manualpage metafile="perf-scaling.xml.meta">
<parentdocument href="./">Miscellaneous Documentation</parentdocument>
-
+
<title>Performance Scaling</title>
-
+
<summary>
-
- <p>The Performance Tuning page in the Apache 1.3 documentation says:
+
+ <p>The Performance Tuning page in the Apache 1.3 documentation says:
</p>
<blockquote><p>
"Apache is a general webserver, which is designed to be
The classic brochureware site is alive and well, but the web has
grown up substantially as a computing application platform and
webmasters may find themselves running dynamic content in Perl, PHP
- or Java, all of which take a toll on performance.
+ or Java, all of which take a toll on performance.
</p>
<p>Therefore, in spite of strides forward in machine speed and
bandwidth allowances, web server performance and web application
performance remain areas of concern. In this documentation several
- aspects of web server performance will be discussed.
+ aspects of web server performance will be discussed.
</p>
-
+
</summary>
-
+
<section id="what-will-and-will-not-be-discussed">
<title>What Will and Will Not Be Discussed
</title>
server hardware, so the existing infrastructure will have to do the
job. You have no desire to compile your own Apache, or to recompile
the operating system kernel. We do assume, though, that you have
- some familiarity with the Apache httpd configuration file.
+ some familiarity with the Apache httpd configuration file.
</p>
-
+
</section>
-
+
<section id="monitoring-your-server">
<title>Monitoring Your Server
</title>
find out how your system is currently performing. By monitoring
your server under real-world load, or artificially generated load,
you can extrapolate its behavior under stress, such as when your
- site is mentioned on Slashdot.
+ site is mentioned on Slashdot.
</p>
-
-
+
+
<section id="monitoring-tools">
<title>Monitoring Tools
</title>
-
-
+
+
<section id="top">
<title>top
</title>
ID, priority and nice values, memory footprint, and
percentage CPU usage. The following example shows multiple
httpd processes (with MPM worker and event) running on an
- Linux (Xen) system:
+ Linux (Xen) system:
</p>
-
+
<example><pre>
top - 23:10:58 up 71 days, 6:14, 4 users, load average: 0.25, 0.53, 0.47
Tasks: 163 total, 1 running, 162 sleeping, 0 stopped, 0 zombie
68 root 15 -5 0 0 0 S 0 0.0 0:06.28 kblockd/0
69 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/1
70 root 15 -5 0 0 0 S 0 0.0 0:00.04 kblockd/2</pre></example>
-
+
<p>Top is a wonderful tool even though it's slightly resource
intensive (when running, its own process is usually in the
top ten CPU gluttons). It is indispensable in determining
determining how many server processes you can run on your
machine. How to do this is described in <a href="#sizing-maxClients">sizing MaxClients</a>.
Top is, however, an interactive tool and running it
- continuously has few if any advantages.
+ continuously has few if any advantages.
</p>
</section>
<section id="free">
both with and without this cache. The free command can be
used to find out how much memory the operating system is
using, as described in the paragraph <a href="#sizing-maxClients">sizing MaxClients</a>.
- The output of free looks like this:
+ The output of free looks like this:
</p>
-
+
<example><pre>
sctemme@brutus:~$ free
total used free shared buffers cached
Swap: 3903784 12540 3891244
</pre></example>
</section>
-
+
<section id="vmstat">
<title>vmstat
</title>
much memory is swapped in and out each second, the number
of processes currently running and sleeping, the number of
interrupts and context switches per second and the usage
- percentages of the CPU.
+ percentages of the CPU.
</p>
<p>
- The following is <code>vmstat</code> output of an idle server:
+ The following is <code>vmstat</code> output of an idle server:
</p>
-
-
+
+
<example><pre>
[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
0 0 0 0 186244 6696 37516 0 0 0 16 41 314 0 0 100
0 0 0 0 186236 6704 37516 0 0 0 9 44 314 0 0 100
</pre></example>
-
+
<p>And this is output of a server that is under a load of one
- hundred simultaneous connections fetching static content:
+ hundred simultaneous connections fetching static content:
</p>
-
+
<example><pre>
[sctemme@GayDeceiver sctemme]$ vmstat 5 3
procs memory swap io system cpu
6 0 1 0 163280 6856 40248 0 0 0 66 6384 1117 42 25 32
11 0 0 0 162780 6864 40436 0 0 0 61 6309 1165 33 28 40
</pre></example>
-
+
<p>The first line gives averages since the last reboot. The
subsequent lines give information for five second
intervals. The second argument tells vmstat to generate
- three reports and then exit.
+ three reports and then exit.
</p>
-
-
+
+
</section>
<section id="se-toolkit">
<title>SE Toolkit
orange or red indicators when utilization of various parts
of the system rises above certain thresholds. Another
included script, Virtual Adrian, applies performance tuning
- metrics according to.
+ metrics according to.
</p>
<p>The SE Toolkit has drifted around for a while and has had
several owners since its inception. It seems that it has
code. SE Toolkit author Richard Pettit has started a new
company, Captive Metrics4 that plans to bring to market a
multiplatform monitoring tool built on the same principles
- as SE Toolkit, written in Java.
+ as SE Toolkit, written in Java.
</p>
-
-
+
+
</section>
<section id="dtrace">
<title>DTrace
</title>
<p>Given that DTrace is available for Solaris, FreeBSD and OS
X, it might be worth exploring it. There's also
- mod_dtrace available for httpd.
+ mod_dtrace available for httpd.
</p>
-
-
+
+
</section>
<section id="mod_status">
<title>mod_status
directive in your <code>httpd.conf</code>,
the <module>mod_status</module>
page will give you more information at the cost of a little
- extra work per request.
+ extra work per request.
</p>
-
-
+
+
</section>
</section>
<section id="web-server-log-files">
from. Historical log file data can give you invaluable insight
into trends in access to your server, which allows you to
predict when your performance needs will overtake your server
- capacity.
+ capacity.
</p>
-
-
+
+
<section id="ErrorLog">
<title>Error Log
</title>
redirected to the error logfile, so any error encountered
by httpd after it opens its logfiles will appear in this
log. This makes it good practice to review the error log
- frequently.
+ frequently.
</p>
<p>Before Apache httpd opens its logfiles, any errors will be
written to the stderr stream. If you start httpd manually,
file is usually a good bet. On Windows, early error
messages are written to the Applications Event Log, which
can be viewed through the Event Viewer in Administrative
- Tools.
+ Tools.
</p>
<p>
The Error Log is configured through the <directive module="core">ErrorLog</directive>
directive can also be used in virtual host containers. The
error log of a virtual host receives only log messages
specific to that virtual host, such as authentication
- failures and 'File not Found' errors.
+ failures and 'File not Found' errors.
</p>
<p>On a server that is visible to the Internet, expect to see a
lot of exploit attempt and worm attacks in the error log. A
port, regardless of which server is actually running or
what applications might be installed. You could block these
attempts using a firewall or <a href="http://www.modsecurity.org/">mod_security</a>,
- but this falls outside the scope of this discussion.
+ but this falls outside the scope of this discussion.
</p>
<p>
The <directive module="core">LogLevel</directive>
directive determines the level of detail included in the
- logs. There are eight log levels as described here:
+ logs. There are eight log levels as described here:
</p>
<table>
<tr>
not be run on debug, but increasing the level of detail in
the error log can be useful during troubleshooting.
Starting with 2.3.8 <directive module="core">LogLevel</directive>
- can be specified on a per module basis:
+ can be specified on a per module basis:
</p>
-
+
<highlight language="config">
LogLevel debug mod_ssl:warn
</highlight>
-
+
<p>
This puts all of the server in debug mode, except for
- <module>mod_ssl</module>, which tends to be very noisy.
+ <module>mod_ssl</module>, which tends to be very noisy.
</p>
-
-
+
+
</section>
<section id="AccessLog">
<title>Access Log
manual. This file exists by default for the main server and can be
configured per virtual host by using the <directive module="mod_log_config">TransferLog</directive>
or <directive module="mod_log_config">CustomLog</directive>
- configuration directive.
+ configuration directive.
</p>
<p>The access logs can be analyzed with any of several free and
commercially available programs. Popular free analysis
be done offline so the web server machine is not burdened
by processing the log files. Most log analysis packages
understand the Common Log Format. The fields in the log
- lines are explained in in the following:
+ lines are explained in in the following:
</p>
-
-
+
+
<example><pre>
195.54.228.42 - - [24/Mar/2007:23:05:11 -0400] "GET /sander/feed/ HTTP/1.1" 200 9747
64.34.165.214 - - [24/Mar/2007:23:10:11 -0400] "GET /sander/feed/atom HTTP/1.1" 200 9068
74.6.72.187 - - [24/Mar/2007:23:18:11 -0400] "GET /sander/2006/09/27/44/ HTTP/1.0" 200 14172
74.6.72.229 - - [24/Mar/2007:23:24:22 -0400] "GET /sander/2006/11/21/os-java/ HTTP/1.0" 200 13457
</pre></example>
-
+
<table>
<tr>
<td>
</td>
</tr>
</table>
-
+
</section>
<section id="rotating-log-files">
<title>Rotating Log Files
file analysis should not be performed on files to which the
server is actively writing. Periodic logfile rotation helps
keep the analysis job manageable, and allows you to keep a
- closer eye on usage trends.
+ closer eye on usage trends.
</p>
<p>On unix systems, you can simply rotate logfiles by giving
the old file a new name using mv. The server will keep
writing to the open file even though it has a new name.
When you send a graceful restart signal to the server, it
will open a new logfile with the configured name. For
- example, you could run a script from cron like this:
+ example, you could run a script from cron like this:
</p>
-
-
+
+
<example>
APACHE=/usr/local/apache2<br />
HTTPD=$APACHE/bin/httpd<br />
$APACHE/logarchive/access_log-`date +%F`<br />
$HTTPD -k graceful
</example>
-
+
<p>This approach also works on Windows, just not as smoothly.
While the httpd process on your Windows server will keep
writing to the log file after it has been renamed, the
Windows Service has to perform will interrupt any requests
currently in progress, and the server is unavailable until
it is started again. Plan for this when you decide the
- timing of your restarts.
+ timing of your restarts.
</p>
<p>
A second approach is to use piped logs. From the
or <directive module="core">ErrorLog
</directive>
directives you can send the log data into any program using
- a pipe character (<code>|</code>). For instance:
+ a pipe character (<code>|</code>). For instance:
</p>
-
+
<example>CustomLog "|/usr/local/apache2/bin/rotatelogs
/var/log/access_log 86400" common
</example>
-
+
<p>The program on the other end of the pipe will receive the
Apache log data on its stdin stream, and can do with this
data whatever it wants. The rotatelogs program that comes
time elapsed or the amount of data written, and leaves the
old log files with a timestamp suffix to its name. This
method for rotating logfiles works well on unix platforms,
- but is currently broken on Windows.
+ but is currently broken on Windows.
</p>
-
-
+
+
</section>
<section id="logging-and-performance">
<title>Logging and Performance
the server log files: the access patterns are very
different. Retrieving content from disk is a read operation
in a fairly random pattern, and log files are written to
- disk sequentially.
+ disk sequentially.
</p>
<p>
Do not run a production server with your error <directive module="core">LogLevel</directive>
information to be written to the error log, including, in
the case of SSL access, complete dumps of BIO read and
write operations. The performance implications are
- significant: use the default warn level instead.
+ significant: use the default warn level instead.
</p>
<p>If your server has more than one virtual host, you may give
each virtual host a separate access logfile. This makes it
directive to have Apache collect several log lines in
memory before writing them to disk. This might yield better
performance, but could affect the order in which the
- server's log is written.
+ server's log is written.
</p>
-
-
+
+
</section>
</section>
<section id="generating-a-test-load">
performance under realistic operating circumstances. Besides
commercial packages such as <a href="http://learnloadrunner.com/">LoadRunner</a>
,there are a number of freely available tools to generate a
- test load against your web server.
+ test load against your web server.
</p>
<ul>
<li>Apache ships with a test program called ab, short for
repeatedly asking for the same file in rapid succession.
You can specify a number of concurrent connections and have
the program run for either a given amount of time or a
- specified number of requests.
+ specified number of requests.
</li>
<li>Another freely available load generator is http load11 .
This program works with a URL file and can be compiled with
- SSL support.
+ SSL support.
</li>
<li>The Apache Software Foundation offers a tool named flood12
. Flood is a fairly sophisticated program that is
- configured through an XML file.
+ configured through an XML file.
</li>
<li>Finally, JMeter13 , a Jakarta subproject, is an all-Java
load-testing tool. While early versions of this application
were slow and difficult to use, the current version 2.1.1
- seems to be versatile and useful.
+ seems to be versatile and useful.
</li>
<li>
<p>ASF external projects, that have proven to be quite
affect the server's response. Also, any data traffic you
generate may be charged against your monthly traffic allowance.
</p>
-
-
+
+
</section>
</section>
<section id="configuring-for-performance">
<title>Configuring for Performance
</title>
-
-
+
+
<section id="apache-configuration">
<title>Httpd Configuration
</title>
multiple request handling threads within each child process. In
2.4 MPMs are no longer hard-wired. They too can be exchanged
via <directive module="mod_so">LoadModule</directive>.
- The default MPM in 2.4 is the event MPM.
+ The default MPM in 2.4 is the event MPM.
</p>
<p>The maximum number of workers, be they pre-forked child
processes or threads within a process, is an indication of how
the maximum number of workers is running, the machine
doesn't hit a hard limit beyond which clients will be
denied access. However, once requests start backing up, system
- performance is likely to degrade.
+ performance is likely to degrade.
</p>
<p>Finally, if the httpd server in question is not executing any third-party
code, via <code>mod_php</code>, <code>mod_perl</code> or similar,
for situations where httpd serves as a thin layer between clients and
backend servers doing the real job, such as a proxy or cache.
</p>
-
-
+
+
<section id="MaxClients">
<title>MaxClients
</title>
number of processes is configurable through the <code>
ServerLimit
</code>
- directive.
+ directive.
</p>
-
-
+
+
</section>
<section id="spinning-threads">
<title>Spinning Threads
value downwards until it is an even factor of
<code>MaxClients</code>.
</p>
-
-
+
+
</section>
<section id="sizing-maxClients">
<title>Sizing MaxClients
your system gets so overloaded that it needs to heavily
swap core memory out to disk, performance will degrade
quickly. The formula for determining <directive module="mpm_common" name="MaxRequestWorkers">MaxClients</directive>
- is fairly simple:
+ is fairly simple:
</p>
-
+
<example>
total RAM - RAM for OS - RAM for external programs<br />
MaxClients =
-------------------------------------------------------<br />
RAM per httpd process
</example>
-
+
<p>The various amounts of memory allocated for the OS, external
programs and the httpd processes is best determined by
observation: use the top and free commands described above
server running. You can also determine the footprint of a
typical web server process from top: most top
implementations have a Resident Size (RSS) column and a
- Shared Memory column.
+ Shared Memory column.
</p>
<p>The difference between these two is the amount of memory
per-process. The shared segment really exists only once and
depends heavily on the number and kind of modules you use.
The best approach to use in determining this need is to
generate a typical test load against your web site and see
- how large the httpd processes become.
+ how large the httpd processes become.
</p>
<p>The RAM for external programs parameter is intended mostly
for CGI programs and scripts that run outside the web
to fork additional child processes, so a higher <code>
MaxClients
</code>
- value may actually be a disadvantage.
+ value may actually be a disadvantage.
</p>
-
-
+
+
</section>
<section id="selecting-your-mpm">
<title>Selecting your MPM
sense. On Linux, the threading implementation actually uses
one process for each thread. Linux processes are relatively
lightweight, but it means that a threaded MPM offers less
- of a performance advantage than in other environments.
+ of a performance advantage than in other environments.
</p>
<p>Running a threaded MPM can cause stability problems in some
situations For instance, should a child process of a
cannot guarantee that all of these are thread-safe. The
good news is that if you are running Apache on Linux, you
can run PHP in the preforked MPM without fear of losing too
- much performance relative to the threaded option.
+ much performance relative to the threaded option.
</p>
-
-
+
+
</section>
<section id="spinning-locks">
<title>Spinning Locks
this time, the parent process may decide to terminate some
children based on its <code>MaxSpareServers
</code>
- directive.
+ directive.
</p>
-
-
+
+
</section>
<section id="the-thundering-herd">
<title>The Thundering Herd
<p>The function of the 'accept mutex' (as this
inter-process lock is called) is to keep request reception
moving along in an orderly fashion. If the lock is absent,
- the server may exhibit the Thundering Herd syndrome.
+ the server may exhibit the Thundering Herd syndrome.
</p>
<p>Consider an American Football team poised on the line of
scrimmage. If the football players were Apache processes
would have to lumber back to the line for the next snap. In
this metaphor, the accept mutex acts as the quarterback,
delivering the connection "ball" to the
- appropriate player process.
+ appropriate player process.
</p>
<p>Moving this much information around is obviously a lot of
work, and, like a smart person, a smart web server tries to
refrain from using an accept mutex. If you run with
multiple listeners (for instance because you have a virtual
host serving SSL requests), it will activate the accept
- mutex to avoid internal conflicts.
+ mutex to avoid internal conflicts.
</p>
<p>
You can manipulate the accept mutex with the <code>
all are available on every platform, and their availability
also depends on compile-time settings. The various locking
mechanisms may place specific demands on system resources:
- manipulate them with care.
+ manipulate them with care.
</p>
<p>There is no compelling reason to disable the accept mutex.
Apache automatically recognizes the single listener
situation described above and knows if it is safe to run
- without mutex on your platform.
+ without mutex on your platform.
</p>
-
-
+
+
</section>
</section>
<section id="tuning-the-operating-system">
are pretty well adjusted straight out of the box and there is
not a lot that needs to be done to make them perform optimally.
However, there are a few things that an administrator can do to
- improve performance.
+ improve performance.
</p>
-
-
+
+
<section id="ram-and-swap-space">
<title>RAM and Swap Space
</title>
virtual hosts-also tends to inflate the process footprint.
Having ample RAM allows you to run Apache with more child
processes, which allows the server to process more
- concurrent requests.
+ concurrent requests.
</p>
<p>While the various platforms treat their virtual memory in
different ways, it is never a good idea to run with less
don't have disk space available and run out of
swappable memory, your machine grinds to a halt. This can
crash your box, requiring a physical reboot for which your
- hosting facility may charge you.
+ hosting facility may charge you.
</p>
<p>Also, such an outage naturally occurs when you least want
it: when the world has found your website and is beating a
and back, but when the load decreases the system should
recover. Remember, you still have <code>MaxClients
</code>
- to keep things in hand.
+ to keep things in hand.
</p>
<p>Most unix-like operating systems use designated disk
partitions for swap space. When a system starts up it finds
installing the operating system, be sure to allocate enough
swap space to accommodate eventual RAM upgrades.
Reassigning disk space on a running system is a cumbersome
- process.
+ process.
</p>
<p>Plan for available hard drive swap space of at least twice
your amount of RAM, perhaps up to four times in situations
</code>
or <code>swap
</code>
- programs.
+ programs.
</p>
-
-
+
+
</section>
<section id="ulimit-files-and-processes">
<title>ulimit: Files and Processes
</title>
<p>Given a machine with plenty of RAM and processor capacity,
you can run hundreds of Apache processes if necessary. . .
- and if your kernel allows it.
+ and if your kernel allows it.
</p>
<p>Consider a situation in which several hundred web servers
are running; if some of these need to spawn CGI processes,
- the maximum number of processes would occur quickly.
+ the maximum number of processes would occur quickly.
</p>
- <p>However, you can change this limit with the command
+ <p>However, you can change this limit with the command
</p>
-
+
<example>
ulimit [-H|-S] -u [newvalue]
</example>
-
+
<p>This must be changed before starting the server, since the
new value will only be available to the current shell and
programs started from it. In newer Linux kernels the
</code>
:
</p>
-
+
<example>
limit [-h] maxproc [newvalue]
</example>
-
+
<p>Similarly, the kernel may limit the number of open files per
process. This is generally not a problem for pre-forked
servers, which just handle one request at a time per
process. Threaded servers, however, serve many requests per
process and much more easily run out of available file
descriptors. You can increase the maximum number of open
- files per process by running the
+ files per process by running the
</p>
-
+
<example>ulimit -n [newvalue]
</example>
-
+
<p>command. Once again, this must be done prior to starting
- Apache.
+ Apache.
</p>
-
-
+
+
</section>
<section id="setting-user-limits-on-system-startup">
<title>Setting User Limits on System Startup
explaining the options. To enable this, make sure that the
file <code>/etc/pam.d/login
</code>
- contains the line
+ contains the line
</p>
-
+
<example>session required /lib/security/pam_limits.so
</example>
-
+
<p>All items can have a 'soft' and a 'hard'
limit: the first is the default setting and the second the
- maximum value for that item.
+ maximum value for that item.
</p>
<p>
In FreeBSD's <code>/etc/login.conf
boot time. These are the same tunables that can be set with
the <code>mdb</code>
kernel debugger during run time. The soft and hard limit
- corresponding to ulimit -u can be set via:
+ corresponding to ulimit -u can be set via:
</p>
-
+
<example>
set rlim_fd_max=65536<br />
set rlim_fd_cur=2048
</example>
-
+
<p>Solaris calculates the maximum number of allowed processes
per user (<code>maxuprc</code>) based on the total amount
available memory on the system (<code>maxusers</code>).
- You can review the numbers with
+ You can review the numbers with
</p>
-
+
<example>sysdef -i | grep maximum
</example>
-
- <p>but it is not recommended to change them.
+
+ <p>but it is not recommended to change them.
</p>
-
-
+
+
</section>
<section id="turn-off-unused-services-and-modules">
<title>Turn Off Unused Services and Modules
services turned on by default. You probably need few of
them. For example, your web server does not need to be
running sendmail, nor is it likely to be an NFS server,
- etc. Turn them off.
+ etc. Turn them off.
</p>
<p>On Red Hat Linux, the chkconfig tool will help you do this
from the command line. On Solaris systems <code>svcs</code>
and <code>svcadm</code>
will show which services are enabled and disable them
- respectively.
+ respectively.
</p>
<p>In a similar fashion, cast a critical eye on the Apache
modules you load. Most binary distributions of Apache
httpd, and pre-installed versions that come with Linux
distributions, have their modules enabled through the
- <directive>LoadModule</directive> directive.
+ <directive>LoadModule</directive> directive.
</p>
<p>Unused modules may be culled: if you don't rely on
their functionality and configuration directives, you can
lines. Read the documentation on each module's
functionality before deciding whether to keep it enabled.
While the performance overhead of an unused module is
- small, it's also unnecessary.
+ small, it's also unnecessary.
</p>
-
-
+
+
</section>
</section>
</section>
Static content consists of simple filespages, images, etc.-on disk
that are very efficiently served. Many operating systems also
automatically cache the contents of frequently accessed files in
- memory.
+ memory.
</p>
<p>Processing dynamic requests, on the contrary, can be much more
involved. Running CGI scripts, handing off requests to an external
significant latency and processing load to a busy web server. Under
many circumstances, performance can be improved by turning popular
dynamic requests into static requests. In this section, two
- approaches to this will be discussed.
+ approaches to this will be discussed.
</p>
-
-
+
+
<section id="making-popular-pages-static">
<title>Making Popular Pages Static
</title>
they are served the pre-rendered page. Queries for, say, yellow
roses will be generated directly from the database. The
mod_rewrite module included with Apache is a great tool to
- implement these substitutions.
+ implement these substitutions.
</p>
-
-
+
+
<section id="example-a-statically-rendered-blog">
<title>Example: A Statically Rendered Blog
</title>
<!--we should provide a more useful example here.
One showing how to make Wordpress or Drupal suck less. -->
-
+
<p>Blosxom is a lightweight web log package that runs as a CGI.
It is written in Perl and uses plain text files for entry
input. Besides running as CGI, Blosxom can be run from the
command line to pre-render blog pages. Pre-rendering pages
to static HTML can yield a significant performance boost in
the event that large numbers of people actually start
- reading your blog.
+ reading your blog.
</p>
<p>To run blosxom for static page generation, edit the CGI
script according to the documentation. Set the $static dir
variable to the <directive>DocumentRoot</directive>
of the web server, and run the script from the command line
- as follows:
+ as follows:
</p>
-
+
<example>$ perl blosxom.cgi -password='whateveryourpassword'
</example>
-
+
<p>This can be run periodically from Cron, after you upload
content, etc. To make Apache substitute the statically
rendered pages for the dynamic content, we'll use
to the configure command. Many binary distributions of
Apache come with <module>mod_rewrite </module> included. The following is an
example of an Apache virtual host that takes advantage of
- pre-rendered blog pages:
+ pre-rendered blog pages:
</p>
-
+
<highlight language="config">
Listen *:8001
<VirtualHost *:8001>
Options +Indexes
Require all granted
RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA]
+ RewriteCond "%{REQUEST_FILENAME}" "!-f"
+ RewriteCond "%{REQUEST_FILENAME}" "!-d"
+ RewriteRule "^(.*)$" "/cgi-bin/blosxom.cgi/$1" [L,QSA]
</Directory>
- RewriteLog /home/sctemme/inst/blog/httpd/logs/rewrite_log
+ RewriteLog "/home/sctemme/inst/blog/httpd/logs/rewrite_log"
RewriteLogLevel 9
ErrorLog /home/sctemme/inst/blog/httpd/logs/error_log
LogLevel debug
</Directory>
</VirtualHost>
</highlight>
-
+
<p>
The <directive>RewriteCond</directive>
and <directive>RewriteRule</directive>
hides the Blosxom CGI from the user-visible URL in their
Location bar. mod_rewrite is a fantastically powerful and
versatile module: investigate it to arrive at a
- configuration that is best for your situation.
+ configuration that is best for your situation.
</p>
-
-
+
+
</section>
</section>
<section id="caching-content-with-mod_cache">
server systems will have more disk available than memory, and
it's good to note that some operating system kernels cache
frequently accessed disk content transparently in memory, so
- replicating this in the server is not very useful.
+ replicating this in the server is not very useful.
</p>
<p>To enable efficient content caching and avoid presenting the
user with stale or invalid content, the application that
generates the actual content has to send the correct response
- headers. Without headers like <code>Etag:</code>,
+ headers. Without headers like <code>Etag:</code>,
<code>Last-Modified:</code> or <code>Expires:</code>,
<module>mod_cache</module> can not make the right decision on whether to cache
the content, serve it from cache or leave it alone. When
option <code>--enable-cache[=shared]</code>
to the configure script. If you use a binary distribution of
Apache httpd, or it came with your port or package collection,
- it may have <module>mod_cache</module> already included.
+ it may have <module>mod_cache</module> already included.
</p>
-
-
+
+
<section id="example-wiki">
<title>Example: wiki.apache.org
</title>
enabled with the following configuration snippet in
<code>httpd.conf</code>:
</p>
-
+
<highlight language="config">
CacheRoot /raid1/cacheroot
CacheEnable disk /
# Always check again after 6 hours
CacheMaxExpire 21600
</highlight>
-
+
<p>This configuration will try to cache any and all content
within its virtual host. It will never cache content for
more than six hours (the <directive module="mod_cache">CacheMaxExpire</directive>
header. The computation using <directive module="mod_cache">CacheLastModifiedFactor</directive>
is based on the assumption that if a page was recently
modified, it is likely to change again in the near future
- and will have to be re-cached.
+ and will have to be re-cached.
</p>
<p>
Do note that it can pay off to <em>disable</em>
TCP packet). For resources larger than 1k it might prove
CPU expensive to calculate the header for each request.
Unfortunately there does currently not exist a way to cache
- these headers.
+ these headers.
</p>
<highlight language="config">
<FilesMatch "\.(jpe?g|png|gif|js|css|x?html|xml)">
FileETag None
</FilesMatch>
</highlight>
-
+
<p>
This will disable the generation of the <code>ETag:</code>
header for most static resources. The server does not
- calculate these headers for dynamic resources.
+ calculate these headers for dynamic resources.
</p>
-
-
+
+
</section>
</section>
</section>
one connection at a time. Worker generally is a good
choice for high-traffic servers because it has a smaller
memory footprint than the prefork MPM.</li>
-
- <li>The <code class="module"><a href="../mod/event.html">event</a></code> MPM is threaded like the
- Worker MPM, but is designed to allow more requests to be
- served simultaneously by passing off some processing work
+
+ <li>The <code class="module"><a href="../mod/event.html">event</a></code> MPM is threaded like the
+ Worker MPM, but is designed to allow more requests to be
+ served simultaneously by passing off some processing work
to supporting threads, freeing up the main threads to work
on new requests.</li>
<strong>accept_mutex_on ();</strong>
for (;;) {
fd_set accept_fds;
-
+
FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
FD_SET (i, &accept_fds);
<pre class="prettyprint lang-c"> void lingering_close (int s)
{
char junk_buffer[2048];
-
+
/* shutdown the sending side */
shutdown (s, 1);
/* just toss away whatever is here */
}
}
-
+
close (s);
}</pre>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1379836:1673917 (outdated) -->
+<!-- English Revision: 1379836:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 105989:1673917 (outdated) -->
+<!-- English Revision: 105989:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1174747:1673917 (outdated) -->
+<!-- English Revision: 1174747:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
<li>The use of a threaded <a href="../mpm.html">mpm</a> may
allow you to handle more simultaneous connections, thereby
- mitigating DoS attacks. Further, the
+ mitigating DoS attacks. Further, the
<code class="module"><a href="../mod/event.html">event</a></code> mpm
uses asynchronous processing to avoid devoting a thread to each
connection. Due to the nature of the OpenSSL library the
directive specific. Always test your changes when creating dependencies
on how directives are merged.</p>
- <p> For modules that don't implement any merging logic, such as
+ <p> For modules that don't implement any merging logic, such as
<code class="directive">mod_access_compat</code>, the behavior in later sections
depends on whether the later section has any directives
- from the module. The configuration is inherited until a change is made,
+ from the module. The configuration is inherited until a change is made,
at which point the configuration is <em>replaced</em> and not merged.</p>
</div></div>
<div class="bottomlang">
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1657687:1673892 (outdated) -->
+<!-- English Revision: 1657687:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 105989:1673892 (outdated) -->
+<!-- English Revision: 105989:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1300924:1673892 (outdated) -->
+<!-- English Revision: 1300924:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.10 and later</td></tr>
</table>
<p>This directive controls whether HTTP trailers are copied into the
- internal representation of HTTP headers. This mergeing occurs when the
- request body has been completely consumed, long after most header
+ internal representation of HTTP headers. This mergeing occurs when the
+ request body has been completely consumed, long after most header
processing would have a chance to examine or modify request headers.</p>
<p>This option is provided for compatibility with releases prior to 2.4.10,
where trailers were always merged.</p>
(nor for ServerName vs. ServerAlias). </p>
<p>The complete list of names in the <code class="directive">VirtualHost</code>
- directive are treated just like a (non wildcard)
+ directive are treated just like a (non wildcard)
<code class="directive">ServerAlias</code>.</p>
<p>If no <code class="directive">ServerName</code> is specified, then the
server attempts to deduce the client visible hostname by performing a
reverse lookup on an IP address of the systems hostname.</p>
-
+
<p>If no port is specified in the
<code class="directive">ServerName</code>, then the server will use the
port from the incoming request. For optimal reliability and
for an acknowledgement of a packet if the send buffer is
full.</li>
- <li>In <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code> and <code class="module"><a href="../mod/mod_cgid.html">mod_cgid</a></code>,
+ <li>In <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code> and <code class="module"><a href="../mod/mod_cgid.html">mod_cgid</a></code>,
the length of time to wait for output from a CGI script.</li>
<li>In <code class="module"><a href="../mod/mod_ext_filter.html">mod_ext_filter</a></code>, the length of time to
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.de.xsl"?>
-<!-- English Revision: 344972:1673917 (outdated) -->
+<!-- English Revision: 344972:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
-<!-- English Revision: 1040494:1673917 (outdated) -->
+<!-- English Revision: 1040494:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1664071:1673917 (outdated) -->
+<!-- English Revision: 1664071:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 669847:1673917 (outdated) -->
+<!-- English Revision: 669847:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1302855:1673917 (outdated) -->
+<!-- English Revision: 1302855:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
in a <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> section.</p>
<div class="note"> <h3>Merging of configuration sections</h3>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</div>
others will be denied.</p>
<div class="note"> <h3>Merging of configuration sections</h3>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</div>
work</a>.</p>
<div class="note"> <h3>Merging of configuration sections</h3>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</div>
be restricted to particular methods by <code class="directive"><a href="../mod/core.html#limit"><Limit></a></code> and <code class="directive"><a href="../mod/core.html#limitexcept"><LimitExcept></a></code> sections.</p>
<div class="note"> <h3>Merging of configuration sections</h3>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</div>
in a <directive module="core" type="section">Limit</directive> section.</p>
<note> <title>Merging of configuration sections</title>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</note>
others will be denied.</p>
<note> <title>Merging of configuration sections</title>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</note>
work</a>.</p>
<note> <title>Merging of configuration sections</title>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</note>
>LimitExcept</directive> sections.</p>
<note> <title>Merging of configuration sections</title>
- <p>When any directive provided by this module is used in a new
+ <p>When any directive provided by this module is used in a new
configuration section, no directives provided by this module are
inherited from previous configuration sections.</p>
</note>
a new location.</p>
<p>When the <code class="directive"><a href="#alias">Alias</a></code>,
- <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+ <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
<code class="directive"><a href="#redirect">Redirect</a></code> directives are used
within a <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
ignored.</p>
<p>When the <code class="directive"><a href="#alias">Alias</a></code>,
- <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+ <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
<code class="directive"><a href="#redirect">Redirect</a></code> directives are used
within a <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code>
section, these directives will take precedence over any globally
defined <code class="directive"><a href="#alias">Alias</a></code>,
- <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
+ <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
<code class="directive"><a href="#redirect">Redirect</a></code> directives.</p>
</div>
</Directory></pre>
- <p>Any number slashes in the <var>URL-path</var> parameter
+ <p>Any number slashes in the <var>URL-path</var> parameter
matches any number of slashes in the requested URL-path.</p>
<p>If the <code class="directive">Alias</code> directive is used within a
a new location.</p>
<p>When the <directive module="mod_alias">Alias</directive>,
- <directive module="mod_alias">ScriptAlias</directive> and
+ <directive module="mod_alias">ScriptAlias</directive> and
<directive module="mod_alias">Redirect</directive> directives are used
within a <directive type="section" module="core">Location</directive>
or <directive type="section" module="core">LocationMatch</directive>
ignored.</p>
<p>When the <directive module="mod_alias">Alias</directive>,
- <directive module="mod_alias">ScriptAlias</directive> and
+ <directive module="mod_alias">ScriptAlias</directive> and
<directive module="mod_alias">Redirect</directive> directives are used
within a <directive type="section" module="core">Location</directive>
or <directive type="section" module="core">LocationMatch</directive>
section, these directives will take precedence over any globally
defined <directive module="mod_alias">Alias</directive>,
- <directive module="mod_alias">ScriptAlias</directive> and
+ <directive module="mod_alias">ScriptAlias</directive> and
<directive module="mod_alias">Redirect</directive> directives.</p>
</section>
</Directory>
</highlight>
- <p>Any number slashes in the <var>URL-path</var> parameter
+ <p>Any number slashes in the <var>URL-path</var> parameter
matches any number of slashes in the requested URL-path.</p>
<p>If the <directive>Alias</directive> directive is used within a
</directivesynopsis>
</modulesynopsis>
-
</directivesynopsis>
</modulesynopsis>
-
<a href="../ja/mod/mod_asis.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
<a href="../ko/mod/mod_asis.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
</div>
+<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
+ anglaise pour les changements récents.</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Envoie des fichiers contenant leurs propres en-têtes
HTTP</td></tr>
<tr><th><a href="module-dict.html#Status">Statut:</a></th><td>Base</td></tr>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision : 1330911 -->
+<!-- English Revision: 1330911:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 420990:1330911 (outdated) -->
+<!-- English Revision: 420990:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1330911 (outdated) -->
+<!-- English Revision: 151408:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<variants>
<variant>en</variant>
- <variant>fr</variant>
+ <variant outdated="yes">fr</variant>
<variant outdated="yes">ja</variant>
<variant outdated="yes">ko</variant>
</variants>
</directivesynopsis>
</modulesynopsis>
-
authenticators and authorizors which participate in one or both
phases.</p>
- <p>FastCGI authorizers can authenticate using user id and password,
+ <p>FastCGI authorizers can authenticate using user id and password,
such as for Basic authentication, or can authenticate using arbitrary
mechanisms.</p>
</div>
<div class="section">
<h2><a name="invocations" id="invocations">Invocation modes</a></h2>
- <p>The invocation modes for FastCGI authorizers supported by this
+ <p>The invocation modes for FastCGI authorizers supported by this
module are distinguished by two characteristics, <em>type</em> and
auth <em>mechanism</em>.</p>
<dt><em>Type</em> <code>authn</code>, <em>mechanism</em>
<code>AuthBasicProvider</code></dt>
- <dd>In this mode,
+ <dd>In this mode,
<code>FCGI_ROLE</code> is set to <code>AUTHORIZER</code> and
<code>FCGI_APACHE_ROLE</code> is set to <code>AUTHENTICATOR</code>.
The application must be defined as provider type <em>authn</em>
AUTHORIZER</code> and <code>FCGI_APACHE_ROLE</code> is set to
<code>AUTHORIZER</code>. The application must be defined as
provider type <em>authz</em> using <code class="directive"><a href="#authnzfcgidefineprovider">
- AuthnzFcgiDefineProvider</a></code>. When invoked, the application
+ AuthnzFcgiDefineProvider</a></code>. When invoked, the application
is expected to authorize the client using the provided user id and other
request data. Example application:
<pre class="prettyprint lang-perl">#!/usr/bin/perl
using <code class="directive"><a href="#authnzfcgidefineprovider">
AuthnzFcgiDefineProvider</a></code>. The application is expected to
handle both authentication and authorization in the same invocation
- using the user id, password, and other request data. The invocation
- occurs during the Apache httpd API authentication phase. If the
+ using the user id, password, and other request data. The invocation
+ occurs during the Apache httpd API authentication phase. If the
application returns 200 and the same provider is invoked during the
authorization phase (via <code class="directive">Require</code>), mod_authnz_fcgi
will return success for the authorization phase without invoking the
die if $ENV{'FCGI_APACHE_ROLE'} ne "AUTHENTICATOR";
die if $ENV{'FCGI_ROLE'} ne "AUTHORIZER";
- # This authorizer assumes that the RequireBasicAuth option of
+ # This authorizer assumes that the RequireBasicAuth option of
# AuthnzFcgiCheckAuthnProvider is On:
die if !$ENV{'REMOTE_PASSWD'};
die if !$ENV{'REMOTE_USER'};
</dd>
</dl>
-
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="examples" id="examples">Additional examples</a></h2>
<ol>
<li>If your application supports the separate authentication and
- authorization roles (<code>AUTHENTICATOR</code> and <code>AUTHORIZER</code>), define
+ authorization roles (<code>AUTHENTICATOR</code> and <code>AUTHORIZER</code>), define
separate providers as follows, even if they map to the same
application:
AuthnzFcgiDefineProvider authz FooAuthz fcgi://localhost:10102/</pre>
- Specify the authn provider on
+ Specify the authn provider on
<code class="directive"><a href="../mod/mod_auth_basic.html#authbasicprovider">AuthBasicProvider</a></code>
and the authz provider on
<code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code>:
</li>
- <li>If your application supports the generic <code>AUTHORIZER</code> role
+ <li>If your application supports the generic <code>AUTHORIZER</code> role
(authentication and authorizer in one invocation), define a
single provider as follows:
<dt>Apache httpd access checker</dt>
<dd>The Apache httpd API <em>access check</em> phase is a separate
phase from authentication and authorization. Some other FastCGI
- implementations implement this phase, which is denoted by the
+ implementations implement this phase, which is denoted by the
setting of <code>FCGI_APACHE_ROLE</code> to <code>ACCESS_CHECKER</code>.</dd>
<dt>Local (Unix) sockets or pipes</dt>
start them.</dd>
<dt>AP_AUTH_INTERNAL_PER_URI</dt>
- <dd>All providers are currently registered as
+ <dd>All providers are currently registered as
AP_AUTH_INTERNAL_PER_CONF, which means that checks are not
performed again for internal subrequests with the same
access control configuration as the initial request.</dd>
<li>General messages for debugging are logged at log level
<code>debug</code>.</li>
<li>Environment variables passed to the application are
- logged at log level <code>trace2</code>. The value of the
+ logged at log level <code>trace2</code>. The value of the
<code>REMOTE_PASSWD</code> variable will be obscured,
- but <strong>any other sensitive data will be visible in the
+ but <strong>any other sensitive data will be visible in the
log</strong>.</li>
<li>All I/O between the module and the FastCGI application,
including all environment variables, will be logged in printable
<dt><em>option</em></dt>
<dd>The following options are supported:
-
+
<dl>
<dt>Authoritative On|Off (default On)</dt>
<dd>This controls whether or not other modules are allowed
evaluated after calling the authorizer, determines the
user. The expression follows <a href="../expr.html">
ap_expr syntax</a> and must resolve to a string. A typical
- use is to reference a <code>Variable-<em>XXX</em></code>
+ use is to reference a <code>Variable-<em>XXX</em></code>
setting returned by the authorizer using an option like
<code>UserExpr "%{reqenv:<em>XXX</em>}"</code>. If
this option is specified and the user id can't be retrieved
<dt><em>provider-name</em></dt>
<dd>This is used to assign a name to the provider which is
- used in other directives such as
+ used in other directives such as
<code class="directive"><a href="../mod/mod_auth_basic.html#authbasicprovider">AuthBasicProvider</a></code>
- and
+ and
<code class="directive"><a href="../mod/mod_authz_core.html#require">Require</a></code>.</dd>
<dt><em>backend-address</em></dt>
authenticators and authorizors which participate in one or both
phases.</p>
- <p>FastCGI authorizers can authenticate using user id and password,
+ <p>FastCGI authorizers can authenticate using user id and password,
such as for Basic authentication, or can authenticate using arbitrary
mechanisms.</p>
</summary>
<section id="invocations"><title>Invocation modes</title>
- <p>The invocation modes for FastCGI authorizers supported by this
+ <p>The invocation modes for FastCGI authorizers supported by this
module are distinguished by two characteristics, <em>type</em> and
auth <em>mechanism</em>.</p>
<dt><em>Type</em> <code>authn</code>, <em>mechanism</em>
<code>AuthBasicProvider</code></dt>
- <dd>In this mode,
+ <dd>In this mode,
<code>FCGI_ROLE</code> is set to <code>AUTHORIZER</code> and
<code>FCGI_APACHE_ROLE</code> is set to <code>AUTHENTICATOR</code>.
The application must be defined as provider type <em>authn</em>
AUTHORIZER</code> and <code>FCGI_APACHE_ROLE</code> is set to
<code>AUTHORIZER</code>. The application must be defined as
provider type <em>authz</em> using <directive module="mod_authnz_fcgi">
- AuthnzFcgiDefineProvider</directive>. When invoked, the application
+ AuthnzFcgiDefineProvider</directive>. When invoked, the application
is expected to authorize the client using the provided user id and other
request data. Example application:
<highlight language="perl">
using <directive module="mod_authnz_fcgi">
AuthnzFcgiDefineProvider</directive>. The application is expected to
handle both authentication and authorization in the same invocation
- using the user id, password, and other request data. The invocation
- occurs during the Apache httpd API authentication phase. If the
+ using the user id, password, and other request data. The invocation
+ occurs during the Apache httpd API authentication phase. If the
application returns 200 and the same provider is invoked during the
authorization phase (via <directive>Require</directive>), mod_authnz_fcgi
will return success for the authorization phase without invoking the
AUTHORIZER</code> and <code>FCGI_APACHE_ROLE</code> is set to
<code>AUTHENTICATOR</code>. The application must be defined as
provider type <em>authn</em> using <directive module="mod_authnz_fcgi">
- AuthnzFcgiDefineProvider</directive>. <directive
+ AuthnzFcgiDefineProvider</directive>. <directive
module="mod_authnz_fcgi">AuthnzFcgiCheckAuthnProvider</directive>
specifies when it is called. Example application:
<highlight language="perl">
die if $ENV{'FCGI_APACHE_ROLE'} ne "AUTHENTICATOR";
die if $ENV{'FCGI_ROLE'} ne "AUTHORIZER";
- # This authorizer assumes that the RequireBasicAuth option of
+ # This authorizer assumes that the RequireBasicAuth option of
# AuthnzFcgiCheckAuthnProvider is On:
die if !$ENV{'REMOTE_PASSWD'};
die if !$ENV{'REMOTE_USER'};
</dd>
</dl>
-
+
</section>
<section id="examples"><title>Additional examples</title>
<ol>
<li>If your application supports the separate authentication and
- authorization roles (<code>AUTHENTICATOR</code> and <code>AUTHORIZER</code>), define
+ authorization roles (<code>AUTHENTICATOR</code> and <code>AUTHORIZER</code>), define
separate providers as follows, even if they map to the same
application:
AuthnzFcgiDefineProvider authz FooAuthz fcgi://localhost:10102/
</highlight>
- Specify the authn provider on
+ Specify the authn provider on
<directive module="mod_auth_basic">AuthBasicProvider</directive>
and the authz provider on
<directive module="mod_authz_core">Require</directive>:
</highlight>
</li>
- <li>If your application supports the generic <code>AUTHORIZER</code> role
+ <li>If your application supports the generic <code>AUTHORIZER</code> role
(authentication and authorizer in one invocation), define a
single provider as follows:
<dt>Apache httpd access checker</dt>
<dd>The Apache httpd API <em>access check</em> phase is a separate
phase from authentication and authorization. Some other FastCGI
- implementations implement this phase, which is denoted by the
+ implementations implement this phase, which is denoted by the
setting of <code>FCGI_APACHE_ROLE</code> to <code>ACCESS_CHECKER</code>.</dd>
<dt>Local (Unix) sockets or pipes</dt>
start them.</dd>
<dt>AP_AUTH_INTERNAL_PER_URI</dt>
- <dd>All providers are currently registered as
+ <dd>All providers are currently registered as
AP_AUTH_INTERNAL_PER_CONF, which means that checks are not
performed again for internal subrequests with the same
access control configuration as the initial request.</dd>
<li>General messages for debugging are logged at log level
<code>debug</code>.</li>
<li>Environment variables passed to the application are
- logged at log level <code>trace2</code>. The value of the
+ logged at log level <code>trace2</code>. The value of the
<code>REMOTE_PASSWD</code> variable will be obscured,
- but <strong>any other sensitive data will be visible in the
+ but <strong>any other sensitive data will be visible in the
log</strong>.</li>
<li>All I/O between the module and the FastCGI application,
including all environment variables, will be logged in printable
<dt><em>provider-name</em></dt>
<dd>This is used to assign a name to the provider which is
- used in other directives such as
+ used in other directives such as
<directive module="mod_auth_basic">AuthBasicProvider</directive>
- and
+ and
<directive module="mod_authz_core">Require</directive>.</dd>
<dt><em>backend-address</em></dt>
<dt><em>option</em></dt>
<dd>The following options are supported:
-
+
<dl>
<dt>Authoritative On|Off (default On)</dt>
<dd>This controls whether or not other modules are allowed
evaluated after calling the authorizer, determines the
user. The expression follows <a href="../expr.html">
ap_expr syntax</a> and must resolve to a string. A typical
- use is to reference a <code>Variable-<em>XXX</em></code>
+ use is to reference a <code>Variable-<em>XXX</em></code>
setting returned by the authorizer using an option like
<code>UserExpr "%{reqenv:<em>XXX</em>}"</code>. If
this option is specified and the user id can't be retrieved
<div class="note"><h3>Nested groups performance</h3>
<p> When <code class="directive">AuthLDAPSubGroupAttribute</code> overlaps with
<code class="directive">AuthLDAPGroupAttribute</code> (as it does by default and
- as required by common LDAP schemas), uncached searching for subgroups in
- large groups can be very slow. If you use large, non-nested groups, keep
+ as required by common LDAP schemas), uncached searching for subgroups in
+ large groups can be very slow. If you use large, non-nested groups, keep
<code class="directive">AuthLDAPMaxSubGroupDepth</code> set to zero.</p>
</div>
directive is useful should you want people to log into a website
using an email address, but a backend application expects the
username as a userid.</p>
- <p> This directive only has effect when this module is used for
+ <p> This directive only has effect when this module is used for
authentication.</p>
</div>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1643416:1673582 (outdated) -->
+<!-- English Revision: 1643416:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
same header repeatedly toggles between ascending and descending
order. These column header links are suppressed with the
<code class="directive"><a href="#indexoptions">IndexOptions</a></code> directive's
- <code><a href="#indexoptions.suppresscolumnsorting">SuppressColumnSorting</a></code>
+ <code><a href="#indexoptions.suppresscolumnsorting">SuppressColumnSorting</a></code>
option.</p>
<p>Note that when the display is sorted by "Size", it's the
<div class="note"><h3>Arguments with path information</h3>
<p>Absolute paths are not currently supported and do not match
anything at runtime. Arguments with relative path information,
- which would normally only be used in htaccess context, are implicitly
+ which would normally only be used in htaccess context, are implicitly
prefixed with '*/' to avoid matching partial directory names.</p>
</div>
<code>FoldersFirst</code> is enabled, subdirectory
<code>Zed</code> will be listed before subdirectory
<code>Beta</code>, which will be listed before normal files
- <code>Gamma</code> and <code>Alpha</code>.
+ <code>Gamma</code> and <code>Alpha</code>.
<strong>This option only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a>
is also enabled.</strong>
</dd>
to wait until all the images have been loaded. If no value is given for
the option, it defaults to the standard height of the icons supplied
with the Apache httpd software.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a> is also enabled.</strong>
space to use for something else. See <code class="directive"><a href="#adddescription">AddDescription</a></code> for information about setting the file
description. See also the <code><a href="#indexoptions.descriptionwidth">DescriptionWidth</a></code>
index option to limit the size of the description column.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a> is also enabled.</strong>
</dd>
<dd>This will suppress the display of the last modification date,
in fancy indexing listings.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a> is also enabled.</strong>
</dd>
by the final specification prohibits <code>img</code> and
<code>hr</code> elements from the <code>pre</code> block (used to
format FancyIndexed listings.)
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a> is also enabled.</strong>
<dt><a name="indexoptions.suppresssize" id="indexoptions.suppresssize">SuppressSize</a></dt>
<dd>This will suppress the file size in fancy indexing listings.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a> is also enabled.</strong>
</dd>
same header repeatedly toggles between ascending and descending
order. These column header links are suppressed with the
<directive module="mod_autoindex">IndexOptions</directive> directive's
- <code><a href="#indexoptions.suppresscolumnsorting">SuppressColumnSorting</a></code>
+ <code><a href="#indexoptions.suppresscolumnsorting">SuppressColumnSorting</a></code>
option.</p>
<p>Note that when the display is sorted by "Size", it's the
<note><title>Arguments with path information</title>
<p>Absolute paths are not currently supported and do not match
anything at runtime. Arguments with relative path information,
- which would normally only be used in htaccess context, are implicitly
+ which would normally only be used in htaccess context, are implicitly
prefixed with '*/' to avoid matching partial directory names.</p>
</note>
<code>FoldersFirst</code> is enabled, subdirectory
<code>Zed</code> will be listed before subdirectory
<code>Beta</code>, which will be listed before normal files
- <code>Gamma</code> and <code>Alpha</code>.
- <strong>This option only has an effect if <a
+ <code>Gamma</code> and <code>Alpha</code>.
+ <strong>This option only has an effect if <a
href="#indexoptions.fancyindexing"><code>FancyIndexing</code></a>
is also enabled.</strong>
</dd>
to wait until all the images have been loaded. If no value is given for
the option, it defaults to the standard height of the icons supplied
with the Apache httpd software.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"
><code>FancyIndexing</code></a> is also enabled.</strong>
description. See also the <code><a
href="#indexoptions.descriptionwidth">DescriptionWidth</a></code>
index option to limit the size of the description column.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"
><code>FancyIndexing</code></a> is also enabled.</strong>
<dd>This will suppress the display of the last modification date,
in fancy indexing listings.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"
><code>FancyIndexing</code></a> is also enabled.</strong>
by the final specification prohibits <code>img</code> and
<code>hr</code> elements from the <code>pre</code> block (used to
format FancyIndexed listings.)
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"
><code>FancyIndexing</code></a> is also enabled.</strong>
id="indexoptions.suppresssize">SuppressSize</a></dt>
<dd>This will suppress the file size in fancy indexing listings.
-
+
<strong>This option
only has an effect if <a href="#indexoptions.fancyindexing"
><code>FancyIndexing</code></a> is also enabled.</strong>
following classes are associated with the various parts of the
listing:</p>
- <table border="1" style="zebra">
+ <table border="1" style="zebra">
<tr><th>Class</th><th>Definition</th></tr>
<tr><td>tr.indexhead</td><td>Header row of listing</td></tr>
<tr><td>th.indexcolicon and td.indexcolicon</td> <td>Icon column</td></tr>
CacheDirLevels 5
CacheDirLength 3
</IfModule>
-
+
# When acting as a proxy, don't cache the list of security updates
CacheDisable http://security.update.server/update-list/
</IfModule></pre>
<code class="directive"><LocationMatch></code> sections are processed
before globally defined <code class="directive">CacheEnable</code> directives.</p>
- <p>When acting as a forward proxy server, <var>url-string</var> must
+ <p>When acting as a forward proxy server, <var>url-string</var> must
minimally begin with a protocol for which caching should be enabled.</p>
<pre class="prettyprint lang-config"># Cache content (normal handler only)
<code class="directive">CacheIgnoreCacheControl</code> directive allows this
behavior to be overridden. <code class="directive">CacheIgnoreCacheControl On</code>
tells the server to attempt to serve the resource from the cache even
- if the request contains no-cache header values.</p>
+ if the request contains no-cache header values.</p>
<pre class="prettyprint lang-config">CacheIgnoreCacheControl On</pre>
</table>
<p>The <code class="directive">CacheLockPath</code> directive allows you to specify the
directory in which the locks are created. If <var>directory</var> is not an absolute
- path, the location specified will be relative to the value of
+ path, the location specified will be relative to the value of
<code class="directive"><a href="../mod/core.html#defaultruntimedir">DefaultRuntimeDir</a></code>.</p>
</div>
CacheDirLevels 5
CacheDirLength 3
</IfModule>
-
+
# When acting as a proxy, don't cache the list of security updates
CacheDisable http://security.update.server/update-list/
</IfModule>
<directive type="section">LocationMatch</directive> sections are processed
before globally defined <directive>CacheEnable</directive> directives.</p>
- <p>When acting as a forward proxy server, <var>url-string</var> must
+ <p>When acting as a forward proxy server, <var>url-string</var> must
minimally begin with a protocol for which caching should be enabled.</p>
<highlight language="config">
<directive>CacheIgnoreCacheControl</directive> directive allows this
behavior to be overridden. <directive>CacheIgnoreCacheControl On</directive>
tells the server to attempt to serve the resource from the cache even
- if the request contains no-cache header values.</p>
+ if the request contains no-cache header values.</p>
<highlight language="config">
CacheIgnoreCacheControl On
<usage>
<p>The <directive>CacheLockPath</directive> directive allows you to specify the
directory in which the locks are created. If <var>directory</var> is not an absolute
- path, the location specified will be relative to the value of
+ path, the location specified will be relative to the value of
<directive module="core">DefaultRuntimeDir</directive>.</p>
</usage>
</directivesynopsis>
<a href="../fr/mod/mod_cern_meta.html" title="Français"> fr </a> |
<a href="../ko/mod/mod_cern_meta.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
</div>
+<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
+ anglaise pour les changements récents.</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>La sémantique des métafichiers du serveur httpd du
CERN</td></tr>
<tr><th><a href="module-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision : 1336590 -->
+<!-- English Revision: 1336590:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 420990:1336590 (outdated) -->
+<!-- English Revision: 420990:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<variants>
<variant>en</variant>
- <variant>fr</variant>
+ <variant outdated="yes">fr</variant>
<variant outdated="yes">ko</variant>
</variants>
</metafile>
<h2><a name="precompressed" id="precompressed">Serving pre-compressed
content</a></h2>
- <p>Since <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> re-compresses content each
+ <p>Since <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> re-compresses content each
time a request is made, some performance benefit can be derived by
pre-compressing the content and telling mod_deflate to serve them
without re-compressing them. This may be accomplished using a
configuration like the following:</p>
<pre class="prettyprint lang-config"><IfModule mod_headers.c>
- # Serve gzip compressed CSS files if they exist
+ # Serve gzip compressed CSS files if they exist
# and the client accepts gzip.
- RewriteCond %{HTTP:Accept-encoding} gzip
- RewriteCond %{REQUEST_FILENAME}\.gz -s
- RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
+ RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+ RewriteCond "%{REQUEST_FILENAME}\.gz" "-s"
+ RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA]
- # Serve gzip compressed JS files if they exist
+ # Serve gzip compressed JS files if they exist
# and the client accepts gzip.
- RewriteCond %{HTTP:Accept-encoding} gzip
- RewriteCond %{REQUEST_FILENAME}\.gz -s
- RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
+ RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+ RewriteCond "%{REQUEST_FILENAME}\.gz" "-s"
+ RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
- RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
- RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
+ RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
+ RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header append Content-Encoding gzip
- # Force proxies to cache gzipped &
+ # Force proxies to cache gzipped &
# non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
how the ETag hader should be altered when a response is compressed.</p>
<dl>
<dt>AddSuffix</dt>
- <dd><p>Append the compression method onto the end of the ETag, causing
- compressed and uncompressed representations to have unique ETags.
- This has been the default since 2.4.0, but prevents serving
- "HTTP Not Modified" (304) responses to conditional requests for
+ <dd><p>Append the compression method onto the end of the ETag, causing
+ compressed and uncompressed representations to have unique ETags.
+ This has been the default since 2.4.0, but prevents serving
+ "HTTP Not Modified" (304) responses to conditional requests for
compressed content.</p></dd>
<dt>NoChange</dt>
<dd><p>Don't change the ETag on a compressed response. This was the default
prior to 2.4.0, but does not satisfy the HTTP/1.1 property that all
representations of the same resource have unique ETags. </p></dd>
<dt>Remove</dt>
- <dd><p>Remove the ETag header from compressed responses. This prevents
- some conditional requests from being possible, but avoids the
+ <dd><p>Remove the ETag header from compressed responses. This prevents
+ some conditional requests from being possible, but avoids the
shortcomings of the preceding options. </p></dd>
</dl>
adding the value to your <a href="../logs.html#accesslog">access log</a>.</p>
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config"> DeflateFilterNote ratio
-
+
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog logs/deflate_log deflate</pre>
</div>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_deflate</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.10 and later</td></tr>
</table>
- <p>The <code class="directive">DeflateInflateLimitRequestBody</code> directive
+ <p>The <code class="directive">DeflateInflateLimitRequestBody</code> directive
specifies the maximum size of an inflated request body. If it is unset,
<code class="directive"><a href="../mod/core.html#limitrequestbody">LimitRequestBody</a></code> is applied to the
inflated body.</p>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="DeflateInflateRatioBurst" id="DeflateInflateRatioBurst">DeflateInflateRatioBurst</a> <a name="deflateinflateratioburst" id="deflateinflateratioburst">Directive</a></h2>
<table class="directive">
-<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximum number of times the inflation ratio for request bodies
+<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>DeflateInflateRatioBurst <var>value</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>3</code></td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_deflate</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.10 and later</td></tr>
</table>
- <p>The <code class="directive">DeflateInflateRatioBurst</code> directive
- specifies the maximum number of times the
- <code class="directive">DeflateInflateRatioLimit</code> can be crossed before
+ <p>The <code class="directive">DeflateInflateRatioBurst</code> directive
+ specifies the maximum number of times the
+ <code class="directive">DeflateInflateRatioLimit</code> can be crossed before
terminating the request.</p>
</div>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_deflate</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.10 and later</td></tr>
</table>
- <p>The <code class="directive">DeflateInflateRatioLimit</code> directive
- specifies the maximum ratio of deflated to inflated size of an
+ <p>The <code class="directive">DeflateInflateRatioLimit</code> directive
+ specifies the maximum ratio of deflated to inflated size of an
inflated request body. This ratio is checked as the body is
- streamed in, and if crossed more than
+ streamed in, and if crossed more than
<code class="directive">DeflateInflateRatioBurst</code> times, the request
will be terminated.</p>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="DeflateInflateRatioBurst" id="DeflateInflateRatioBurst">DeflateInflateRatioBurst</a> <a name="deflateinflateratioburst" id="deflateinflateratioburst">ディレクティブ</a></h2>
<table class="directive">
-<tr><th><a href="directive-dict.html#Description">説明:</a></th><td>Maximum number of times the inflation ratio for request bodies
+<tr><th><a href="directive-dict.html#Description">説明:</a></th><td>Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr><th><a href="directive-dict.html#Syntax">構文:</a></th><td><code>DeflateInflateRatioBurst <var>value</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">デフォルト:</a></th><td><code>3</code></td></tr>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="DeflateInflateRatioBurst" id="DeflateInflateRatioBurst">DeflateInflateRatioBurst</a> <a name="deflateinflateratioburst" id="deflateinflateratioburst">Áö½Ã¾î</a></h2>
<table class="directive">
-<tr><th><a href="directive-dict.html#Description">¼³¸í:</a></th><td>Maximum number of times the inflation ratio for request bodies
+<tr><th><a href="directive-dict.html#Description">¼³¸í:</a></th><td>Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr><th><a href="directive-dict.html#Syntax">¹®¹ý:</a></th><td><code>DeflateInflateRatioBurst <var>value</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">±âº»°ª:</a></th><td><code>3</code></td></tr>
<highlight language="config">
SetOutputFilter DEFLATE
-SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
+SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
</highlight>
<p>If you want to restrict the compression to particular MIME types
<section id="precompressed"><title>Serving pre-compressed
content</title>
- <p>Since <module>mod_deflate</module> re-compresses content each
+ <p>Since <module>mod_deflate</module> re-compresses content each
time a request is made, some performance benefit can be derived by
pre-compressing the content and telling mod_deflate to serve them
without re-compressing them. This may be accomplished using a
<highlight language="config">
<IfModule mod_headers.c>
- # Serve gzip compressed CSS files if they exist
+ # Serve gzip compressed CSS files if they exist
# and the client accepts gzip.
- RewriteCond %{HTTP:Accept-encoding} gzip
- RewriteCond %{REQUEST_FILENAME}\.gz -s
- RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
+ RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+ RewriteCond "%{REQUEST_FILENAME}\.gz" "-s"
+ RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA]
- # Serve gzip compressed JS files if they exist
+ # Serve gzip compressed JS files if they exist
# and the client accepts gzip.
- RewriteCond %{HTTP:Accept-encoding} gzip
- RewriteCond %{REQUEST_FILENAME}\.gz -s
- RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
+ RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+ RewriteCond "%{REQUEST_FILENAME}\.gz" "-s"
+ RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
- RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
- RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
+ RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
+ RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header append Content-Encoding gzip
- # Force proxies to cache gzipped &
+ # Force proxies to cache gzipped &
# non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
<example><title>Example</title>
<highlight language="config">
DeflateFilterNote ratio
-
+
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog logs/deflate_log deflate
</highlight>
how the ETag hader should be altered when a response is compressed.</p>
<dl>
<dt>AddSuffix</dt>
- <dd><p>Append the compression method onto the end of the ETag, causing
- compressed and uncompressed representations to have unique ETags.
- This has been the default since 2.4.0, but prevents serving
- "HTTP Not Modified" (304) responses to conditional requests for
+ <dd><p>Append the compression method onto the end of the ETag, causing
+ compressed and uncompressed representations to have unique ETags.
+ This has been the default since 2.4.0, but prevents serving
+ "HTTP Not Modified" (304) responses to conditional requests for
compressed content.</p></dd>
<dt>NoChange</dt>
<dd><p>Don't change the ETag on a compressed response. This was the default
prior to 2.4.0, but does not satisfy the HTTP/1.1 property that all
representations of the same resource have unique ETags. </p></dd>
<dt>Remove</dt>
- <dd><p>Remove the ETag header from compressed responses. This prevents
- some conditional requests from being possible, but avoids the
+ <dd><p>Remove the ETag header from compressed responses. This prevents
+ some conditional requests from being possible, but avoids the
shortcomings of the preceding options. </p></dd>
</dl>
</usage>
<compatibility>2.4.10 and later</compatibility>
<usage>
- <p>The <directive>DeflateInflateLimitRequestBody</directive> directive
+ <p>The <directive>DeflateInflateLimitRequestBody</directive> directive
specifies the maximum size of an inflated request body. If it is unset,
<directive module="core">LimitRequestBody</directive> is applied to the
inflated body.</p>
<compatibility>2.4.10 and later</compatibility>
<usage>
- <p>The <directive>DeflateInflateRatioLimit</directive> directive
- specifies the maximum ratio of deflated to inflated size of an
+ <p>The <directive>DeflateInflateRatioLimit</directive> directive
+ specifies the maximum ratio of deflated to inflated size of an
inflated request body. This ratio is checked as the body is
- streamed in, and if crossed more than
+ streamed in, and if crossed more than
<directive>DeflateInflateRatioBurst</directive> times, the request
will be terminated.</p>
</usage>
<directivesynopsis>
<name>DeflateInflateRatioBurst</name>
-<description>Maximum number of times the inflation ratio for request bodies
+<description>Maximum number of times the inflation ratio for request bodies
can be crossed</description>
<syntax>DeflateInflateRatioBurst <var>value</var></syntax>
<default>3</default>
<compatibility>2.4.10 and later</compatibility>
<usage>
- <p>The <directive>DeflateInflateRatioBurst</directive> directive
- specifies the maximum number of times the
- <directive>DeflateInflateRatioLimit</directive> can be crossed before
+ <p>The <directive>DeflateInflateRatioBurst</directive> directive
+ specifies the maximum number of times the
+ <directive>DeflateInflateRatioLimit</directive> can be crossed before
terminating the request.</p>
</usage>
</directivesynopsis>
</modulesynopsis>
-
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1655917:1673892 (outdated) -->
+<!-- English Revision: 1655917:1673930 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 420990:1673892 (outdated) -->
+<!-- English Revision: 420990:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1673892 (outdated) -->
+<!-- English Revision: 151408:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
</directivesynopsis>
</modulesynopsis>
-
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in 2.4.8 and later. Releases prior to 2.4 implicitly
act as if "DirectoryCheckHandler ON" was specified.</td></tr>
</table>
- <p>The <code class="directive">DirectoryCheckHandler</code> directive determines
+ <p>The <code class="directive">DirectoryCheckHandler</code> directive determines
whether <code class="module"><a href="../mod/mod_dir.html">mod_dir</a></code> should check for directory indexes or
add trailing slashes when some other handler has been configured for
- the current URL. Handlers can be set by directives such as
- <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code> or by other modules at
+ the current URL. Handlers can be set by directives such as
+ <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code> or by other modules at
runtime. </p>
<p> In releases prior to 2.4, this module did not take any action if any
- other handler was configured for a URL. This allows directory indexes to
- be served even when a <code class="directive">SetHandler</code> directive is
+ other handler was configured for a URL. This allows directory indexes to
+ be served even when a <code class="directive">SetHandler</code> directive is
specified for an entire directory, but it can also result in some conflicts
- with other modules.</p>
+ with other modules.</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<compatibility>Available in 2.4.8 and later. Releases prior to 2.4 implicitly
act as if "DirectoryCheckHandler ON" was specified.</compatibility>
<usage>
- <p>The <directive>DirectoryCheckHandler</directive> directive determines
+ <p>The <directive>DirectoryCheckHandler</directive> directive determines
whether <module>mod_dir</module> should check for directory indexes or
add trailing slashes when some other handler has been configured for
- the current URL. Handlers can be set by directives such as
- <directive module="core">SetHandler</directive> or by other modules at
+ the current URL. Handlers can be set by directives such as
+ <directive module="core">SetHandler</directive> or by other modules at
runtime. </p>
<p> In releases prior to 2.4, this module did not take any action if any
- other handler was configured for a URL. This allows directory indexes to
- be served even when a <directive>SetHandler</directive> directive is
+ other handler was configured for a URL. This allows directory indexes to
+ be served even when a <directive>SetHandler</directive> directive is
specified for an entire directory, but it can also result in some conflicts
- with other modules.</p>
+ with other modules.</p>
</usage>
</directivesynopsis>
# core directive to cause the new filter to
# be run on output
SetOutputFilter c-to-html
-
+
# mod_mime directive to set the type of .c
# files to text/c
AddType text/c .c
ExtFilterDefine gzip mode=output cmd=/bin/gzip
<Location "/gzipped">
-
+
# core directive to cause the gzip filter to be
# run on output
SetOutputFilter gzip
-
+
# mod_headers directive to add
# "Content-Encoding: gzip" header field
Header set Content-Encoding gzip
# core directive to cause the new filter to
# be run on output
SetOutputFilter c-to-html
-
+
# mod_mime directive to set the type of .c
# files to text/c
AddType text/c .c
ExtFilterDefine gzip mode=output cmd=/bin/gzip
<Location "/gzipped">
-
+
# core directive to cause the gzip filter to be
# run on output
SetOutputFilter gzip
-
+
# mod_headers directive to add
# "Content-Encoding: gzip" header field
Header set Content-Encoding gzip
With two arguments it applies to a <var>filter-name</var> whenever the
filter runs <em>any</em> provider.</p>
- <p>Flags specified with this directive are merged with the flags
- that underlying providers may have registerd with
+ <p>Flags specified with this directive are merged with the flags
+ that underlying providers may have registerd with
<code class="module"><a href="../mod/mod_filter.html">mod_filter</a></code>. For example, a filter may internally specify
- the equivalent of <code>change=yes</code>, but a particular
+ the equivalent of <code>change=yes</code>, but a particular
configuration of the module can override with <code>change=no</code>.
</p>
<dl>
<dt><code>change=yes|no</code></dt>
- <dd>Specifies whether the filter changes the content, including possibly
+ <dd>Specifies whether the filter changes the content, including possibly
the content length. The "no" argument is supported in 2.4.7 and later.</dd>
<dt><code>change=1:1</code></dt>
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1432444 (outdated) -->
+<!-- English Revision: 151408:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<p>These variables can be for example used to show only log messages
for particular URI using <code>journalctl</code>:
</p>
-
+
<pre class="prettyprint lang-">journalctl REQUEST_URI=/index.html -a</pre>
-
+
<p>For more examples, see systemd-journalctl documentation.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
instead of a filename enables logging via systemd-journald(8)
if the system supports it.
</p>
-
+
<pre class="prettyprint lang-config">ErrorLog journald</pre>
<p>These variables can be for example used to show only log messages
for particular URI using <code>journalctl</code>:
</p>
-
+
<highlight>journalctl REQUEST_URI=/index.html -a</highlight>
-
+
<p>For more examples, see systemd-journalctl documentation.</p>
</section>
instead of a filename enables logging via systemd-journald(8)
if the system supports it.
</p>
-
+
<highlight language="config">
ErrorLog journald
</highlight>
connection pool. The default value of -1, and any other negative value,
allows connections of any age to be reused.</p>
- <p>For performance reasons, the reference time used by this directive is
+ <p>For performance reasons, the reference time used by this directive is
based on when the LDAP connection is returned to the pool, not the time
of the last successful I/O with the LDAP server. </p>
time is not updated if no backend LDAP conncetions were needed. Second,
the reference time uses the time the HTTP request was received instead
of the time the request is completed.</p>
-
+
<div class="note"><p>This timeout defaults to units of seconds, but accepts
suffixes for milliseconds (ms), minutes (min), and hours (h).
</p></div>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_ldap</td></tr>
</table>
- <p>Specifies the path of the shared memory cache file. If not set,
+ <p>Specifies the path of the shared memory cache file. If not set,
anonymous shared memory will be used if the platform supports it.</p>
<p>If <var>file-path</var> is not an absolute path, the location specified
- will be relative to the value of
+ will be relative to the value of
<code class="directive"><a href="../mod/core.html#defaultruntimedir">DefaultRuntimeDir</a></code>.</p>
</div>
<contextlist><context>server config</context></contextlist>
<usage>
- <p>Specifies the path of the shared memory cache file. If not set,
+ <p>Specifies the path of the shared memory cache file. If not set,
anonymous shared memory will be used if the platform supports it.</p>
<p>If <var>file-path</var> is not an absolute path, the location specified
- will be relative to the value of
+ will be relative to the value of
<directive module="core">DefaultRuntimeDir</directive>.</p>
</usage>
</directivesynopsis>
connection pool. The default value of -1, and any other negative value,
allows connections of any age to be reused.</p>
- <p>For performance reasons, the reference time used by this directive is
+ <p>For performance reasons, the reference time used by this directive is
based on when the LDAP connection is returned to the pool, not the time
of the last successful I/O with the LDAP server. </p>
time is not updated if no backend LDAP conncetions were needed. Second,
the reference time uses the time the HTTP request was received instead
of the time the request is completed.</p>
-
+
<note><p>This timeout defaults to units of seconds, but accepts
suffixes for milliseconds (ms), minutes (min), and hours (h).
</p></note>
<div class="note">
<p>Note: The '^' character at the start of three-character formats
- has no significance, but it must be the first character of any newly
- added three-character format to avoid potential conflicts with log
- formats that use literals adjacent to a format specifier, such as
+ has no significance, but it must be the first character of any newly
+ added three-character format to avoid potential conflicts with log
+ formats that use literals adjacent to a format specifier, such as
"%Dus".</p>
</div>
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config">LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common</pre>
</div>
-
+
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<note>
<p>Note: The '^' character at the start of three-character formats
- has no significance, but it must be the first character of any newly
- added three-character format to avoid potential conflicts with log
- formats that use literals adjacent to a format specifier, such as
+ has no significance, but it must be the first character of any newly
+ added three-character format to avoid potential conflicts with log
+ formats that use literals adjacent to a format specifier, such as
"%Dus".</p>
</note>
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common
</highlight>
</example>
-
+
</usage>
</directivesynopsis>
Be sure to check the CHANGES file before upgrading.</div>
<div class="warning"><h3>Warning</h3>
-<p>This module holds a great deal of power over httpd, which is both a
-strength and a potential security risk. It is <strong>not</strong> recommended
-that you use this module on a server that is shared with users you do not
+<p>This module holds a great deal of power over httpd, which is both a
+strength and a potential security risk. It is <strong>not</strong> recommended
+that you use this module on a server that is shared with users you do not
trust, as it can be abused to change the internal workings of httpd.</p>
</div>
<tr>
<td>Quick handler</td>
<td><code class="directive"><a href="#luaquickhandler">LuaQuickHandler</a></code></td>
- <td>This is the first hook that will be called after a request has
+ <td>This is the first hook that will be called after a request has
been mapped to a host or virtual host</td>
</tr>
<tr class="odd">
<td>Translate name</td>
<td><code class="directive"><a href="#luahooktranslatename">LuaHookTranslateName</a></code></td>
- <td>This phase translates the requested URI into a filename on the
+ <td>This phase translates the requested URI into a filename on the
system. Modules such as <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> and
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> operate in this phase.</td>
</tr>
<tr>
<td>Map to storage</td>
<td><code class="directive"><a href="#luahookmaptostorage">LuaHookMapToStorage</a></code></td>
- <td>This phase maps files to their physical, cached or external/proxied storage.
+ <td>This phase maps files to their physical, cached or external/proxied storage.
It can be used by proxy or caching modules</td>
</tr>
<tr class="odd">
<td>Check Access</td>
<td><code class="directive"><a href="#luahookaccesschecker">LuaHookAccessChecker</a></code></td>
- <td>This phase checks whether a client has access to a resource. This
+ <td>This phase checks whether a client has access to a resource. This
phase is run before the user is authenticated, so beware.
</td>
</tr>
</tr>
<tr class="odd">
<td>Check Authorization</td>
- <td><code class="directive"><a href="#luahookauthchecker">LuaHookAuthChecker</a></code> or
+ <td><code class="directive"><a href="#luahookauthchecker">LuaHookAuthChecker</a></code> or
<code class="directive"><a href="#luaauthzprovider">LuaAuthzProvider</a></code></td>
- <td>This phase authorizes a user based on the negotiated credentials, such as
+ <td>This phase authorizes a user based on the negotiated credentials, such as
user ID, client certificate etc.
</td>
</tr>
<tr>
<td>Check Type</td>
<td><code class="directive"><a href="#luahooktypechecker">LuaHookTypeChecker</a></code></td>
- <td>This phase checks the requested file and assigns a content type and
+ <td>This phase checks the requested file and assigns a content type and
a handler to it</td>
</tr>
<tr class="odd">
<td>Fixups</td>
<td><code class="directive"><a href="#luahookfixups">LuaHookFixups</a></code></td>
- <td>This is the final "fix anything" phase before the content handlers
+ <td>This is the final "fix anything" phase before the content handlers
are run. Any last-minute changes to the request should be made here.</td>
</tr>
<tr>
<td>Content handler</td>
<td>fx. <code>.lua</code> files or through <code class="directive"><a href="#luamaphandler">LuaMapHandler</a></code></td>
- <td>This is where the content is handled. Files are read, parsed, some are run,
+ <td>This is where the content is handled. Files are read, parsed, some are run,
and the result is sent to the client</td>
</tr>
<tr class="odd">
<td>Logging</td>
<td><code class="directive"><a href="#luahooklog">LuaHookLog</a></code></td>
- <td>Once a request has been handled, it enters several logging phases,
+ <td>Once a request has been handled, it enters several logging phases,
which logs the request in either the error or access log. Mod_lua
is able to hook into the start of this and control logging output.</td>
</tr>
</table>
-<p>Hook functions are passed the request object as their only argument
-(except for LuaAuthzProvider, which also gets passed the arguments from
+<p>Hook functions are passed the request object as their only argument
+(except for LuaAuthzProvider, which also gets passed the arguments from
the Require directive).
They can return any value, depending on the hook, but most commonly
they'll return OK, DONE, or DECLINED, which you can write in Lua as
<td><code>ap_auth_type</code></td>
<td>string</td>
<td>no</td>
- <td>If an authentication check was made, this is set to the type
+ <td>If an authentication check was made, this is set to the type
of authentication (f.x. <code>basic</code>)</td>
</tr>
<tr>
<td><code>args</code></td>
<td>string</td>
<td>yes</td>
- <td>The query string arguments extracted from the request
+ <td>The query string arguments extracted from the request
(f.x. <code>foo=bar&name=johnsmith</code>)</td>
</tr>
<tr class="odd">
<td><code>assbackwards</code></td>
<td>boolean</td>
<td>no</td>
- <td>Set to true if this is an HTTP/0.9 style request
+ <td>Set to true if this is an HTTP/0.9 style request
(e.g. <code>GET /foo</code> (with no headers) )</td>
</tr>
<tr>
<td><code>content_type</code></td>
<td>string</td>
<td>yes</td>
- <td>The content type of the current request, as determined in the
+ <td>The content type of the current request, as determined in the
type_check phase (f.x. <code>image/gif</code> or <code>text/html</code>)</td>
</tr>
<tr>
<td><code>filename</code></td>
<td>string</td>
<td>yes</td>
- <td>The file name that the request maps to, f.x. /www/example.com/foo.txt. This can be
- changed in the translate-name or map-to-storage phases of a request to allow the
+ <td>The file name that the request maps to, f.x. /www/example.com/foo.txt. This can be
+ changed in the translate-name or map-to-storage phases of a request to allow the
default handler (or script handlers) to serve a different file than what was requested.</td>
</tr>
<tr class="odd">
<td><code>handler</code></td>
<td>string</td>
<td>yes</td>
- <td>The name of the <a href="../handler.html">handler</a> that should serve this request, f.x.
- <code>lua-script</code> if it is to be served by mod_lua. This is typically set by the
- <code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code> or <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code>
- directives, but could also be set via mod_lua to allow another handler to serve up a specific request
+ <td>The name of the <a href="../handler.html">handler</a> that should serve this request, f.x.
+ <code>lua-script</code> if it is to be served by mod_lua. This is typically set by the
+ <code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code> or <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code>
+ directives, but could also be set via mod_lua to allow another handler to serve up a specific request
that would otherwise not be served by it.
</td>
</tr>
<td><code>headers_in</code></td>
<td>table</td>
<td>yes</td>
- <td>MIME header environment from the request. This contains headers such as <code>Host,
+ <td>MIME header environment from the request. This contains headers such as <code>Host,
User-Agent, Referer</code> and so on.</td>
</tr>
<tr class="odd">
<td><code>proxyreq</code></td>
<td>string</td>
<td>yes</td>
- <td>Denotes whether this is a proxy request or not. This value is generally set in
+ <td>Denotes whether this is a proxy request or not. This value is generally set in
the post_read_request/translate_name phase of a request.</td>
</tr>
<tr>
end</pre>
-<pre class="prettyprint lang-lua">r:parseargs() -- returns two tables; one standard key/value table for regular GET data,
+<pre class="prettyprint lang-lua">r:parseargs() -- returns two tables; one standard key/value table for regular GET data,
-- and one for multi-value data (fx. foo=1&foo=2&foo=3):
local GET, GETMULTI = r:parseargs()
<pre class="prettyprint lang-lua">r:parsebody([sizeLimit]) -- parse the request body as a POST and return two lua tables,
-- just like r:parseargs().
- -- An optional number may be passed to specify the maximum number
+ -- An optional number may be passed to specify the maximum number
-- of bytes to parse. Default is 8192 bytes:
-
+
local POST, POSTMULTI = r:parsebody(1024*1024)
r:puts("Your name is: " .. POST['name'] or "Unknown")</pre>
<pre class="prettyprint lang-lua">r:requestbody(filename) -- Reads and returns the request body of a request.
-- If 'filename' is specified, it instead saves the
-- contents to that file:
-
+
local input = r:requestbody()
r:puts("You sent the following request body to me:\n")
r:puts(input)</pre>
end</pre>
-<pre class="prettyprint lang-lua">r:runtime_dir_relative(filename) -- Compute the name of a run-time file (e.g., shared memory "file")
+<pre class="prettyprint lang-lua">r:runtime_dir_relative(filename) -- Compute the name of a run-time file (e.g., shared memory "file")
-- relative to the appropriate run-time directory.</pre>
-<pre class="prettyprint lang-lua">r:server_info() -- Returns a table containing server information, such as
+<pre class="prettyprint lang-lua">r:server_info() -- Returns a table containing server information, such as
-- the name of the httpd executable file, mpm used etc.</pre>
<pre class="prettyprint lang-lua">r.strcmp_match(string, pattern) -- Checks if 'string' matches 'pattern' using strcmp_match (globs).
-- fx. whether 'www.example.com' matches '*.example.com':
-
+
local match = r.strcmp_match("foobar.com", "foo*.com")
-if match then
+if match then
r:puts("foobar.com matches foo*.com")
end</pre>
<pre class="prettyprint lang-lua">r:custom_response(status_code, string) -- Construct and set a custom response for a given status code.
-- This works much like the ErrorDocument directive:
-
+
r:custom_response(404, "Baleted!")</pre>
<pre class="prettyprint lang-lua">r:ivm_set("key", value) -- Set an Inter-VM variable to hold a specific value.
-- These values persist even though the VM is gone or not being used,
-- and so should only be used if MaxConnectionsPerChild is > 0
- -- Values can be numbers, strings and booleans, and are stored on a
+ -- Values can be numbers, strings and booleans, and are stored on a
-- per process basis (so they won't do much good with a prefork mpm)
-
+
r:ivm_get("key") -- Fetches a variable set by ivm_set. Returns the contents of the variable
-- if it exists or nil if no such variable exists.
-
+
-- An example getter/setter that saves a global variable outside the VM:
function handle(r)
-- First VM to call this will get no value, and will have to create it
<h2><a name="modifying_buckets" id="modifying_buckets">Modifying contents with Lua filters</a></h2>
<p>
- Filter functions implemented via <code class="directive"><a href="#luainputfilter">LuaInputFilter</a></code>
- or <code class="directive"><a href="#luaoutputfilter">LuaOutputFilter</a></code> are designed as
- three-stage non-blocking functions using coroutines to suspend and resume a
- function as buckets are sent down the filter chain. The core structure of
+ Filter functions implemented via <code class="directive"><a href="#luainputfilter">LuaInputFilter</a></code>
+ or <code class="directive"><a href="#luaoutputfilter">LuaOutputFilter</a></code> are designed as
+ three-stage non-blocking functions using coroutines to suspend and resume a
+ function as buckets are sent down the filter chain. The core structure of
such a function is:
</p>
<pre class="prettyprint lang-lua">function filter(r)
return -- This would skip this filter.
end
-- Regardless of whether we have data to prepend, a yield MUST be called here.
- -- Note that only output filters can prepend data. Input filters must use the
+ -- Note that only output filters can prepend data. Input filters must use the
-- final stage to append data to the content.
coroutine.yield([optional header to be prepended to the content])
-
- -- After we have yielded, buckets will be sent to us, one by one, and we can
+
+ -- After we have yielded, buckets will be sent to us, one by one, and we can
-- do whatever we want with them and then pass on the result.
-- Buckets are stored in the global variable 'bucket', so we create a loop
-- that checks if 'bucket' is not nil:
coroutine.yield(output) -- Return our new content to the filter chain
end
- -- Once the buckets are gone, 'bucket' is set to nil, which will exit the
+ -- Once the buckets are gone, 'bucket' is set to nil, which will exit the
-- loop and land us here. Anything extra we want to append to the content
- -- can be done by doing a final yield here. Both input and output filters
+ -- can be done by doing a final yield here. Both input and output filters
-- can append data to the content in this phase.
coroutine.yield([optional footer to be appended to the content])
end</pre>
<h3><a name="result_sets" id="result_sets">Working with result sets</a></h3>
- <p>The result set returned by <code>db:select</code> or by the prepared statement functions
+ <p>The result set returned by <code>db:select</code> or by the prepared statement functions
created through <code>db:prepare</code> can be used to
fetch rows synchronously or asynchronously, depending on the row number specified:<br />
<code>result(0)</code> fetches all rows in a synchronous manner, returning a table of rows.<br />
local row = result(1234) -- Fetch row number 1234, asynchronously
local row = result(-1, true) -- Fetch the next available row, using row names as key indexes.</pre>
- <p>One can construct a function that returns an iterative function to iterate over all rows
+ <p>One can construct a function that returns an iterative function to iterate over all rows
in a synchronous or asynchronous way, depending on the async argument:
</p>
<pre class="prettyprint lang-lua">function rows(resultset, async)
<p>Database handles should be closed using <code>database:close()</code> when they are no longer
- needed. If you do not close them manually, they will eventually be garbage collected and
- closed by mod_lua, but you may end up having too many unused connections to the database
+ needed. If you do not close them manually, they will eventually be garbage collected and
+ closed by mod_lua, but you may end up having too many unused connections to the database
if you leave the closing up to mod_lua. Essentially, the following two measures are
the same:
</p>
<h3><a name="database_caveat" id="database_caveat">Precautions when working with databases</a></h3>
- <p>Although the standard <code>query</code> and <code>run</code> functions are freely
- available, it is recommended that you use prepared statements whenever possible, to
- both optimize performance (if your db handle lives on for a long time) and to minimize
+ <p>Although the standard <code>query</code> and <code>run</code> functions are freely
+ available, it is recommended that you use prepared statements whenever possible, to
+ both optimize performance (if your db handle lives on for a long time) and to minimize
the risk of SQL injection attacks. <code>run</code> and <code>query</code> should only
- be used when there are no variables inserted into a statement (a static statement).
+ be used when there are no variables inserted into a statement (a static statement).
When using dynamic statements, use <code>db:prepare</code> or <code>db:prepared</code>.
</p>
</table>
<p>Add your hook to the access_checker phase. An access checker
hook function usually returns OK, DECLINED, or HTTP_FORBIDDEN.</p>
- <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
+ <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></div>
</div>
return apache2.OK
end</pre>
- <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
+ <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></div>
</div>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table>
<p>
- This simple logging hook allows you to run a function when httpd enters the
- logging phase of a request. With it, you can append data to your own logs,
- manipulate data before the regular log is written, or prevent a log entry
+ This simple logging hook allows you to run a function when httpd enters the
+ logging phase of a request. With it, you can append data to your own logs,
+ manipulate data before the regular log is written, or prevent a log entry
from being created. To prevent the usual logging from happening, simply return
- <code>apache2.DONE</code> in your logging handler, otherwise return
+ <code>apache2.DONE</code> in your logging handler, otherwise return
<code>apache2.OK</code> to tell httpd to log as normal.
</p>
<p>Example:</p>
-- flip a coin:
-- If 1, then we write to our own Lua log and tell httpd not to log
-- in the main log.
- -- If 2, then we just sanitize the output a bit and tell httpd to
+ -- If 2, then we just sanitize the output a bit and tell httpd to
-- log the sanitized bits.
if math.random(1,2) == 1 then
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table>
- <p>Like <code class="directive">LuaHookTranslateName</code> but executed at the
+ <p>Like <code class="directive">LuaHookTranslateName</code> but executed at the
map-to-storage phase of a request. Modules like mod_cache run at this phase,
which makes for an interesting example on what to do here:</p>
<pre class="prettyprint lang-config">LuaHookMapToStorage /path/to/lua/script.lua check_cache</pre>
<pre class="prettyprint lang-lua">require"apache2"
cached_files = {}
-function read_file(filename)
+function read_file(filename)
local input = io.open(filename, "r")
if input then
local data = input:read("*a")
<div class="note"><h3>Context</h3><p>This directive is not valid in <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>, <code class="directive"><a href="../mod/core.html#files"><Files></a></code>, or htaccess
context.</p></div>
- <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
+ <div class="note"><h3>Ordering</h3><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></div>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table><p>
- This directive provides a hook for the type_checker phase of the request processing.
- This phase is where requests are assigned a content type and a handler, and thus can
+ This directive provides a hook for the type_checker phase of the request processing.
+ This phase is where requests are assigned a content type and a handler, and thus can
be used to modify the type and handler based on input:
</p>
<pre class="prettyprint lang-config">LuaHookTypeChecker /path/to/lua/script.lua type_checker</pre>
more specific section are run <em>after</em> those defined in the more
generic section (LuaInherit parent-first). You can reverse this order, or
make the parent context not apply at all.</p>
-
+
<p> In previous 2.3.x releases, the default was effectively to ignore LuaHook*
directives from parent configuration sections.</p>
</div>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.5 and later</td></tr>
</table>
-<p>Provides a means of adding a Lua function as an input filter.
-As with output filters, input filters work as coroutines,
-first yielding before buffers are sent, then yielding whenever
-a bucket needs to be passed down the chain, and finally (optionally)
-yielding anything that needs to be appended to the input data. The
-global variable <code>bucket</code> holds the buckets as they are passed
+<p>Provides a means of adding a Lua function as an input filter.
+As with output filters, input filters work as coroutines,
+first yielding before buffers are sent, then yielding whenever
+a bucket needs to be passed down the chain, and finally (optionally)
+yielding anything that needs to be appended to the input data. The
+global variable <code>bucket</code> holds the buckets as they are passed
onto the Lua script:
</p>
end</pre>
<p>
-See "<a href="#modifying_buckets">Modifying contents with Lua
+See "<a href="#modifying_buckets">Modifying contents with Lua
filters</a>" for more information.
</p>
<p>This directive matches a uri pattern to invoke a specific
handler function in a specific file. It uses PCRE regular
expressions to match the uri, and supports interpolating
- match groups into both the file path and the function name.
+ match groups into both the file path and the function name.
Be careful writing your regular expressions to avoid security
issues.</p>
<div class="example"><h3>Examples:</h3><pre class="prettyprint lang-config">LuaMapHandler /(\w+)/(\w+) /scripts/$1.lua handle_$2</pre>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>2.4.5 and later</td></tr>
</table>
-<p>Provides a means of adding a Lua function as an output filter.
-As with input filters, output filters work as coroutines,
-first yielding before buffers are sent, then yielding whenever
-a bucket needs to be passed down the chain, and finally (optionally)
-yielding anything that needs to be appended to the input data. The
-global variable <code>bucket</code> holds the buckets as they are passed
+<p>Provides a means of adding a Lua function as an output filter.
+As with input filters, output filters work as coroutines,
+first yielding before buffers are sent, then yielding whenever
+a bucket needs to be passed down the chain, and finally (optionally)
+yielding anything that needs to be appended to the input data. The
+global variable <code>bucket</code> holds the buckets as they are passed
onto the Lua script:
</p>
end</pre>
<p>
-As with the input filter, the output filter supports denying/skipping a filter
+As with the input filter, the output filter supports denying/skipping a filter
if it is deemed unwanted:
</p>
<pre class="prettyprint lang-lua">function output_filter(r)
end</pre>
<div class="note"><h3>Lua filters with <code class="module"><a href="../mod/mod_filter.html">mod_filter</a></code></h3>
-<p> When a Lua filter is used as the underlying provider via the
-<code class="directive"><a href="../mod/mod_filter.html#filterprovider">FilterProvider</a></code> directive, filtering
+<p> When a Lua filter is used as the underlying provider via the
+<code class="directive"><a href="../mod/mod_filter.html#filterprovider">FilterProvider</a></code> directive, filtering
will only work when the <var>filter-name</var> is identical to the <var>provider-name</var>.
</p> </div>
<p>
-See "<a href="#modifying_buckets">Modifying contents with Lua filters</a>" for more
+See "<a href="#modifying_buckets">Modifying contents with Lua filters</a>" for more
information.
</p>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table>
<p>
- This phase is run immediately after the request has been mapped to a virtal host,
- and can be used to either do some request processing before the other phases kick
- in, or to serve a request without the need to translate, map to storage et cetera.
- As this phase is run before anything else, directives such as <code class="directive"><a href="../mod/core.html#location"><Location></a></code> or <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> are void in this phase, just as
+ This phase is run immediately after the request has been mapped to a virtal host,
+ and can be used to either do some request processing before the other phases kick
+ in, or to serve a request without the need to translate, map to storage et cetera.
+ As this phase is run before anything else, directives such as <code class="directive"><a href="../mod/core.html#location"><Location></a></code> or <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> are void in this phase, just as
URIs have not been properly parsed yet.
</p>
<div class="note"><h3>Context</h3><p>This directive is not valid in <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code>, <code class="directive"><a href="../mod/core.html#files"><Files></a></code>, or htaccess
<dt>conn:</dt> <dd>Same as request but attached to the connection_rec</dd>
- <dt>thread:</dt> <dd>Use the interpreter for the lifetime of the thread
+ <dt>thread:</dt> <dd>Use the interpreter for the lifetime of the thread
handling the request (only available with threaded MPMs).</dd>
<dt>server:</dt> <dd>This one is different than others because the
server scope is quite long lived, and multiple threads
will have the same server_rec. To accommodate this,
server scoped Lua states are stored in an apr
- resource list. The <code>min</code> and <code>max</code> arguments
- specify the minimum and maximum number of Lua states to keep in the
+ resource list. The <code>min</code> and <code>max</code> arguments
+ specify the minimum and maximum number of Lua states to keep in the
pool.</dd>
</dl>
<p>
- Generally speaking, the <code>thread</code> and <code>server</code> scopes
- execute roughly 2-3 times faster than the rest, because they don't have to
- spawn new Lua states on every request (especially with the event MPM, as
- even keepalive requests will use a new thread for each request). If you are
- satisfied that your scripts will not have problems reusing a state, then
- the <code>thread</code> or <code>server</code> scopes should be used for
- maximum performance. While the <code>thread</code> scope will provide the
- fastest responses, the <code>server</code> scope will use less memory, as
- states are pooled, allowing f.x. 1000 threads to share only 100 Lua states,
+ Generally speaking, the <code>thread</code> and <code>server</code> scopes
+ execute roughly 2-3 times faster than the rest, because they don't have to
+ spawn new Lua states on every request (especially with the event MPM, as
+ even keepalive requests will use a new thread for each request). If you are
+ satisfied that your scripts will not have problems reusing a state, then
+ the <code>thread</code> or <code>server</code> scopes should be used for
+ maximum performance. While the <code>thread</code> scope will provide the
+ fastest responses, the <code>server</code> scope will use less memory, as
+ states are pooled, allowing f.x. 1000 threads to share only 100 Lua states,
thus using only 10% of the memory required by the <code>thread</code> scope.
</p>
Be sure to check the CHANGES file before upgrading.</note>
<note type="warning"><title>Warning</title>
-<p>This module holds a great deal of power over httpd, which is both a
-strength and a potential security risk. It is <strong>not</strong> recommended
-that you use this module on a server that is shared with users you do not
+<p>This module holds a great deal of power over httpd, which is both a
+strength and a potential security risk. It is <strong>not</strong> recommended
+that you use this module on a server that is shared with users you do not
trust, as it can be abused to change the internal workings of httpd.</p>
</note>
<tr>
<td>Quick handler</td>
<td><directive module="mod_lua">LuaQuickHandler</directive></td>
- <td>This is the first hook that will be called after a request has
+ <td>This is the first hook that will be called after a request has
been mapped to a host or virtual host</td>
</tr>
<tr>
<td>Translate name</td>
<td><directive module="mod_lua">LuaHookTranslateName</directive></td>
- <td>This phase translates the requested URI into a filename on the
+ <td>This phase translates the requested URI into a filename on the
system. Modules such as <module>mod_alias</module> and
<module>mod_rewrite</module> operate in this phase.</td>
</tr>
<tr>
<td>Map to storage</td>
<td><directive module="mod_lua">LuaHookMapToStorage</directive></td>
- <td>This phase maps files to their physical, cached or external/proxied storage.
+ <td>This phase maps files to their physical, cached or external/proxied storage.
It can be used by proxy or caching modules</td>
</tr>
<tr>
<td>Check Access</td>
<td><directive module="mod_lua">LuaHookAccessChecker</directive></td>
- <td>This phase checks whether a client has access to a resource. This
+ <td>This phase checks whether a client has access to a resource. This
phase is run before the user is authenticated, so beware.
</td>
</tr>
</tr>
<tr>
<td>Check Authorization</td>
- <td><directive module="mod_lua">LuaHookAuthChecker</directive> or
+ <td><directive module="mod_lua">LuaHookAuthChecker</directive> or
<directive module="mod_lua">LuaAuthzProvider</directive></td>
- <td>This phase authorizes a user based on the negotiated credentials, such as
+ <td>This phase authorizes a user based on the negotiated credentials, such as
user ID, client certificate etc.
</td>
</tr>
<tr>
<td>Check Type</td>
<td><directive module="mod_lua">LuaHookTypeChecker</directive></td>
- <td>This phase checks the requested file and assigns a content type and
+ <td>This phase checks the requested file and assigns a content type and
a handler to it</td>
</tr>
<tr>
<td>Fixups</td>
<td><directive module="mod_lua">LuaHookFixups</directive></td>
- <td>This is the final "fix anything" phase before the content handlers
+ <td>This is the final "fix anything" phase before the content handlers
are run. Any last-minute changes to the request should be made here.</td>
</tr>
<tr>
<td>Content handler</td>
<td>fx. <code>.lua</code> files or through <directive module="mod_lua">LuaMapHandler</directive></td>
- <td>This is where the content is handled. Files are read, parsed, some are run,
+ <td>This is where the content is handled. Files are read, parsed, some are run,
and the result is sent to the client</td>
</tr>
<tr>
<td>Logging</td>
<td><directive module="mod_lua">LuaHookLog</directive></td>
- <td>Once a request has been handled, it enters several logging phases,
+ <td>Once a request has been handled, it enters several logging phases,
which logs the request in either the error or access log. Mod_lua
is able to hook into the start of this and control logging output.</td>
</tr>
</table>
-<p>Hook functions are passed the request object as their only argument
-(except for LuaAuthzProvider, which also gets passed the arguments from
+<p>Hook functions are passed the request object as their only argument
+(except for LuaAuthzProvider, which also gets passed the arguments from
the Require directive).
They can return any value, depending on the hook, but most commonly
they'll return OK, DONE, or DECLINED, which you can write in Lua as
<td><code>ap_auth_type</code></td>
<td>string</td>
<td>no</td>
- <td>If an authentication check was made, this is set to the type
+ <td>If an authentication check was made, this is set to the type
of authentication (f.x. <code>basic</code>)</td>
</tr>
<tr>
<td><code>args</code></td>
<td>string</td>
<td>yes</td>
- <td>The query string arguments extracted from the request
+ <td>The query string arguments extracted from the request
(f.x. <code>foo=bar&name=johnsmith</code>)</td>
</tr>
<tr>
<td><code>assbackwards</code></td>
<td>boolean</td>
<td>no</td>
- <td>Set to true if this is an HTTP/0.9 style request
+ <td>Set to true if this is an HTTP/0.9 style request
(e.g. <code>GET /foo</code> (with no headers) )</td>
</tr>
<tr>
<td><code>content_type</code></td>
<td>string</td>
<td>yes</td>
- <td>The content type of the current request, as determined in the
+ <td>The content type of the current request, as determined in the
type_check phase (f.x. <code>image/gif</code> or <code>text/html</code>)</td>
</tr>
<tr>
<td><code>filename</code></td>
<td>string</td>
<td>yes</td>
- <td>The file name that the request maps to, f.x. /www/example.com/foo.txt. This can be
- changed in the translate-name or map-to-storage phases of a request to allow the
+ <td>The file name that the request maps to, f.x. /www/example.com/foo.txt. This can be
+ changed in the translate-name or map-to-storage phases of a request to allow the
default handler (or script handlers) to serve a different file than what was requested.</td>
</tr>
<tr>
<td><code>handler</code></td>
<td>string</td>
<td>yes</td>
- <td>The name of the <a href="../handler.html">handler</a> that should serve this request, f.x.
- <code>lua-script</code> if it is to be served by mod_lua. This is typically set by the
- <directive module="mod_mime">AddHandler</directive> or <directive module="core">SetHandler</directive>
- directives, but could also be set via mod_lua to allow another handler to serve up a specific request
+ <td>The name of the <a href="../handler.html">handler</a> that should serve this request, f.x.
+ <code>lua-script</code> if it is to be served by mod_lua. This is typically set by the
+ <directive module="mod_mime">AddHandler</directive> or <directive module="core">SetHandler</directive>
+ directives, but could also be set via mod_lua to allow another handler to serve up a specific request
that would otherwise not be served by it.
</td>
</tr>
<td><code>headers_in</code></td>
<td>table</td>
<td>yes</td>
- <td>MIME header environment from the request. This contains headers such as <code>Host,
+ <td>MIME header environment from the request. This contains headers such as <code>Host,
User-Agent, Referer</code> and so on.</td>
</tr>
<tr>
<td><code>proxyreq</code></td>
<td>string</td>
<td>yes</td>
- <td>Denotes whether this is a proxy request or not. This value is generally set in
+ <td>Denotes whether this is a proxy request or not. This value is generally set in
the post_read_request/translate_name phase of a request.</td>
</tr>
<tr>
</highlight>
<highlight language="lua">
-r:parseargs() -- returns two tables; one standard key/value table for regular GET data,
+r:parseargs() -- returns two tables; one standard key/value table for regular GET data,
-- and one for multi-value data (fx. foo=1&foo=2&foo=3):
local GET, GETMULTI = r:parseargs()
<highlight language="lua">
r:parsebody([sizeLimit]) -- parse the request body as a POST and return two lua tables,
-- just like r:parseargs().
- -- An optional number may be passed to specify the maximum number
+ -- An optional number may be passed to specify the maximum number
-- of bytes to parse. Default is 8192 bytes:
-
+
local POST, POSTMULTI = r:parsebody(1024*1024)
r:puts("Your name is: " .. POST['name'] or "Unknown")
</highlight>
<highlight language="lua">
r:construct_url(string) -- Constructs an URL from an URI
-local url = r:construct_url(r.uri)
+local url = r:construct_url(r.uri)
</highlight>
<highlight language="lua">
r:requestbody(filename) -- Reads and returns the request body of a request.
-- If 'filename' is specified, it instead saves the
-- contents to that file:
-
+
local input = r:requestbody()
r:puts("You sent the following request body to me:\n")
r:puts(input)
</highlight>
<highlight language="lua">
-r:runtime_dir_relative(filename) -- Compute the name of a run-time file (e.g., shared memory "file")
- -- relative to the appropriate run-time directory.
+r:runtime_dir_relative(filename) -- Compute the name of a run-time file (e.g., shared memory "file")
+ -- relative to the appropriate run-time directory.
</highlight>
<highlight language="lua">
-r:server_info() -- Returns a table containing server information, such as
+r:server_info() -- Returns a table containing server information, such as
-- the name of the httpd executable file, mpm used etc.
</highlight>
<highlight language="lua">
r.strcmp_match(string, pattern) -- Checks if 'string' matches 'pattern' using strcmp_match (globs).
-- fx. whether 'www.example.com' matches '*.example.com':
-
+
local match = r.strcmp_match("foobar.com", "foo*.com")
-if match then
+if match then
r:puts("foobar.com matches foo*.com")
end
</highlight>
<highlight language="lua">
r:custom_response(status_code, string) -- Construct and set a custom response for a given status code.
-- This works much like the ErrorDocument directive:
-
+
r:custom_response(404, "Baleted!")
</highlight>
r:ivm_set("key", value) -- Set an Inter-VM variable to hold a specific value.
-- These values persist even though the VM is gone or not being used,
-- and so should only be used if MaxConnectionsPerChild is > 0
- -- Values can be numbers, strings and booleans, and are stored on a
+ -- Values can be numbers, strings and booleans, and are stored on a
-- per process basis (so they won't do much good with a prefork mpm)
-
+
r:ivm_get("key") -- Fetches a variable set by ivm_set. Returns the contents of the variable
-- if it exists or nil if no such variable exists.
-
+
-- An example getter/setter that saves a global variable outside the VM:
function handle(r)
-- First VM to call this will get no value, and will have to create it
<section id="modifying_buckets">
<title>Modifying contents with Lua filters</title>
<p>
- Filter functions implemented via <directive module="mod_lua">LuaInputFilter</directive>
- or <directive module="mod_lua">LuaOutputFilter</directive> are designed as
- three-stage non-blocking functions using coroutines to suspend and resume a
- function as buckets are sent down the filter chain. The core structure of
+ Filter functions implemented via <directive module="mod_lua">LuaInputFilter</directive>
+ or <directive module="mod_lua">LuaOutputFilter</directive> are designed as
+ three-stage non-blocking functions using coroutines to suspend and resume a
+ function as buckets are sent down the filter chain. The core structure of
such a function is:
</p>
<highlight language="lua">
return -- This would skip this filter.
end
-- Regardless of whether we have data to prepend, a yield MUST be called here.
- -- Note that only output filters can prepend data. Input filters must use the
+ -- Note that only output filters can prepend data. Input filters must use the
-- final stage to append data to the content.
coroutine.yield([optional header to be prepended to the content])
-
- -- After we have yielded, buckets will be sent to us, one by one, and we can
+
+ -- After we have yielded, buckets will be sent to us, one by one, and we can
-- do whatever we want with them and then pass on the result.
-- Buckets are stored in the global variable 'bucket', so we create a loop
-- that checks if 'bucket' is not nil:
coroutine.yield(output) -- Return our new content to the filter chain
end
- -- Once the buckets are gone, 'bucket' is set to nil, which will exit the
+ -- Once the buckets are gone, 'bucket' is set to nil, which will exit the
-- loop and land us here. Anything extra we want to append to the content
- -- can be done by doing a final yield here. Both input and output filters
+ -- can be done by doing a final yield here. Both input and output filters
-- can append data to the content in this phase.
coroutine.yield([optional footer to be appended to the content])
end
</section>
<section id="result_sets">
<title>Working with result sets</title>
- <p>The result set returned by <code>db:select</code> or by the prepared statement functions
+ <p>The result set returned by <code>db:select</code> or by the prepared statement functions
created through <code>db:prepare</code> can be used to
fetch rows synchronously or asynchronously, depending on the row number specified:<br/>
<code>result(0)</code> fetches all rows in a synchronous manner, returning a table of rows.<br/>
local row = result(1234) -- Fetch row number 1234, asynchronously
local row = result(-1, true) -- Fetch the next available row, using row names as key indexes.
</highlight>
- <p>One can construct a function that returns an iterative function to iterate over all rows
+ <p>One can construct a function that returns an iterative function to iterate over all rows
in a synchronous or asynchronous way, depending on the async argument:
</p>
<highlight language="lua">
<title>Closing a database connection</title>
<p>Database handles should be closed using <code>database:close()</code> when they are no longer
- needed. If you do not close them manually, they will eventually be garbage collected and
- closed by mod_lua, but you may end up having too many unused connections to the database
+ needed. If you do not close them manually, they will eventually be garbage collected and
+ closed by mod_lua, but you may end up having too many unused connections to the database
if you leave the closing up to mod_lua. Essentially, the following two measures are
the same:
</p>
</section>
<section id="database_caveat">
<title>Precautions when working with databases</title>
- <p>Although the standard <code>query</code> and <code>run</code> functions are freely
- available, it is recommended that you use prepared statements whenever possible, to
- both optimize performance (if your db handle lives on for a long time) and to minimize
+ <p>Although the standard <code>query</code> and <code>run</code> functions are freely
+ available, it is recommended that you use prepared statements whenever possible, to
+ both optimize performance (if your db handle lives on for a long time) and to minimize
the risk of SQL injection attacks. <code>run</code> and <code>query</code> should only
- be used when there are no variables inserted into a statement (a static statement).
+ be used when there are no variables inserted into a statement (a static statement).
When using dynamic statements, use <code>db:prepare</code> or <code>db:prepared</code>.
</p>
</section>
<dt>conn:</dt> <dd>Same as request but attached to the connection_rec</dd>
- <dt>thread:</dt> <dd>Use the interpreter for the lifetime of the thread
+ <dt>thread:</dt> <dd>Use the interpreter for the lifetime of the thread
handling the request (only available with threaded MPMs).</dd>
<dt>server:</dt> <dd>This one is different than others because the
server scope is quite long lived, and multiple threads
will have the same server_rec. To accommodate this,
server scoped Lua states are stored in an apr
- resource list. The <code>min</code> and <code>max</code> arguments
- specify the minimum and maximum number of Lua states to keep in the
+ resource list. The <code>min</code> and <code>max</code> arguments
+ specify the minimum and maximum number of Lua states to keep in the
pool.</dd>
</dl>
<p>
- Generally speaking, the <code>thread</code> and <code>server</code> scopes
- execute roughly 2-3 times faster than the rest, because they don't have to
- spawn new Lua states on every request (especially with the event MPM, as
- even keepalive requests will use a new thread for each request). If you are
- satisfied that your scripts will not have problems reusing a state, then
- the <code>thread</code> or <code>server</code> scopes should be used for
- maximum performance. While the <code>thread</code> scope will provide the
- fastest responses, the <code>server</code> scope will use less memory, as
- states are pooled, allowing f.x. 1000 threads to share only 100 Lua states,
+ Generally speaking, the <code>thread</code> and <code>server</code> scopes
+ execute roughly 2-3 times faster than the rest, because they don't have to
+ spawn new Lua states on every request (especially with the event MPM, as
+ even keepalive requests will use a new thread for each request). If you are
+ satisfied that your scripts will not have problems reusing a state, then
+ the <code>thread</code> or <code>server</code> scopes should be used for
+ maximum performance. While the <code>thread</code> scope will provide the
+ fastest responses, the <code>server</code> scope will use less memory, as
+ states are pooled, allowing f.x. 1000 threads to share only 100 Lua states,
thus using only 10% of the memory required by the <code>thread</code> scope.
</p>
</usage>
<p>This directive matches a uri pattern to invoke a specific
handler function in a specific file. It uses PCRE regular
expressions to match the uri, and supports interpolating
- match groups into both the file path and the function name.
+ match groups into both the file path and the function name.
Be careful writing your regular expressions to avoid security
issues.</p>
<example><title>Examples:</title>
type="section" module="core">Files</directive>, or htaccess
context.</p></note>
- <note><title>Ordering</title><p>The optional arguments "early" or "late"
+ <note><title>Ordering</title><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></note>
</usage>
<override>All</override>
<usage>
<p>
- This simple logging hook allows you to run a function when httpd enters the
- logging phase of a request. With it, you can append data to your own logs,
- manipulate data before the regular log is written, or prevent a log entry
+ This simple logging hook allows you to run a function when httpd enters the
+ logging phase of a request. With it, you can append data to your own logs,
+ manipulate data before the regular log is written, or prevent a log entry
from being created. To prevent the usual logging from happening, simply return
- <code>apache2.DONE</code> in your logging handler, otherwise return
+ <code>apache2.DONE</code> in your logging handler, otherwise return
<code>apache2.OK</code> to tell httpd to log as normal.
</p>
<p>Example:</p>
-- flip a coin:
-- If 1, then we write to our own Lua log and tell httpd not to log
-- in the main log.
- -- If 2, then we just sanitize the output a bit and tell httpd to
+ -- If 2, then we just sanitize the output a bit and tell httpd to
-- log the sanitized bits.
if math.random(1,2) == 1 then
</contextlist>
<override>All</override>
<usage>
- <p>Like <directive>LuaHookTranslateName</directive> but executed at the
+ <p>Like <directive>LuaHookTranslateName</directive> but executed at the
map-to-storage phase of a request. Modules like mod_cache run at this phase,
which makes for an interesting example on what to do here:</p>
<highlight language="config">
require"apache2"
cached_files = {}
-function read_file(filename)
+function read_file(filename)
local input = io.open(filename, "r")
if input then
local data = input:read("*a")
<!-- Third argument does not work at the moment!
<compatibility>The optional third argument is supported in 2.3.15 and later</compatibility>
<usage><p>...</p>
- <note><title>Ordering</title><p>The optional arguments "early" or "late"
+ <note><title>Ordering</title><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></note>
</usage>
-->
</contextlist>
<override>All</override>
<usage><p>
- This directive provides a hook for the type_checker phase of the request processing.
- This phase is where requests are assigned a content type and a handler, and thus can
+ This directive provides a hook for the type_checker phase of the request processing.
+ This phase is where requests are assigned a content type and a handler, and thus can
be used to modify the type and handler based on input:
</p>
<highlight language="config">
return apache2.OK
end
</highlight>
- <note><title>Ordering</title><p>The optional arguments "early" or "late"
+ <note><title>Ordering</title><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></note>
</usage>
</directivesynopsis>
<usage>
<p>Add your hook to the access_checker phase. An access checker
hook function usually returns OK, DECLINED, or HTTP_FORBIDDEN.</p>
- <note><title>Ordering</title><p>The optional arguments "early" or "late"
+ <note><title>Ordering</title><p>The optional arguments "early" or "late"
control when this script runs relative to other modules.</p></note>
</usage>
</directivesynopsis>
more specific section are run <em>after</em> those defined in the more
generic section (LuaInherit parent-first). You can reverse this order, or
make the parent context not apply at all.</p>
-
+
<p> In previous 2.3.x releases, the default was effectively to ignore LuaHook*
directives from parent configuration sections.</p></usage>
</directivesynopsis>
<override>All</override>
<usage>
<p>
- This phase is run immediately after the request has been mapped to a virtal host,
- and can be used to either do some request processing before the other phases kick
- in, or to serve a request without the need to translate, map to storage et cetera.
+ This phase is run immediately after the request has been mapped to a virtal host,
+ and can be used to either do some request processing before the other phases kick
+ in, or to serve a request without the need to translate, map to storage et cetera.
As this phase is run before anything else, directives such as <directive
type="section" module="core">Location</directive> or <directive
- type="section" module="core">Directory</directive> are void in this phase, just as
+ type="section" module="core">Directory</directive> are void in this phase, just as
URIs have not been properly parsed yet.
</p>
<note><title>Context</title><p>This directive is not valid in <directive
<compatibility>2.4.5 and later</compatibility>
<usage>
-<p>Provides a means of adding a Lua function as an input filter.
-As with output filters, input filters work as coroutines,
-first yielding before buffers are sent, then yielding whenever
-a bucket needs to be passed down the chain, and finally (optionally)
-yielding anything that needs to be appended to the input data. The
-global variable <code>bucket</code> holds the buckets as they are passed
+<p>Provides a means of adding a Lua function as an input filter.
+As with output filters, input filters work as coroutines,
+first yielding before buffers are sent, then yielding whenever
+a bucket needs to be passed down the chain, and finally (optionally)
+yielding anything that needs to be appended to the input data. The
+global variable <code>bucket</code> holds the buckets as they are passed
onto the Lua script:
</p>
end
</highlight>
<p>
-See "<a href="#modifying_buckets">Modifying contents with Lua
+See "<a href="#modifying_buckets">Modifying contents with Lua
filters</a>" for more information.
</p>
</usage>
<compatibility>2.4.5 and later</compatibility>
<usage>
-<p>Provides a means of adding a Lua function as an output filter.
-As with input filters, output filters work as coroutines,
-first yielding before buffers are sent, then yielding whenever
-a bucket needs to be passed down the chain, and finally (optionally)
-yielding anything that needs to be appended to the input data. The
-global variable <code>bucket</code> holds the buckets as they are passed
+<p>Provides a means of adding a Lua function as an output filter.
+As with input filters, output filters work as coroutines,
+first yielding before buffers are sent, then yielding whenever
+a bucket needs to be passed down the chain, and finally (optionally)
+yielding anything that needs to be appended to the input data. The
+global variable <code>bucket</code> holds the buckets as they are passed
onto the Lua script:
</p>
end
</highlight>
<p>
-As with the input filter, the output filter supports denying/skipping a filter
+As with the input filter, the output filter supports denying/skipping a filter
if it is deemed unwanted:
</p>
<highlight language="lua">
end
</highlight>
<note><title>Lua filters with <module>mod_filter</module></title>
-<p> When a Lua filter is used as the underlying provider via the
-<directive module="mod_filter">FilterProvider</directive> directive, filtering
+<p> When a Lua filter is used as the underlying provider via the
+<directive module="mod_filter">FilterProvider</directive> directive, filtering
will only work when the <var>filter-name</var> is identical to the <var>provider-name</var>.
</p> </note>
<p>
-See "<a href="#modifying_buckets">Modifying contents with Lua filters</a>" for more
+See "<a href="#modifying_buckets">Modifying contents with Lua filters</a>" for more
information.
</p>
<p>Parameter names should begin with a sigil such as <code>$</code>,
<code>%</code>, or <code>@</code>, so that they are clearly
identifiable, and also in order to help deal with interactions with
-other directives, such as the core <code class="directive"><a href="../mod/core.html#define">Define</a></code> directive. Failure to do so will
+other directives, such as the core <code class="directive"><a href="../mod/core.html#define">Define</a></code> directive. Failure to do so will
result in a warning. Nevertheless, you are encouraged to have a good
knowledge of your entire server configuration in order to avoid reusing
the same variables in different scopes, which can cause confusion.</p>
<code>%</code>, or <code>@</code>, so that they are clearly
identifiable, and also in order to help deal with interactions with
other directives, such as the core <directive
-module="core">Define</directive> directive. Failure to do so will
+module="core">Define</directive> directive. Failure to do so will
result in a warning. Nevertheless, you are encouraged to have a good
knowledge of your entire server configuration in order to avoid reusing
the same variables in different scopes, which can cause confusion.</p>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 659902:1673892 (outdated) -->
+<!-- English Revision: 659902:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<dd>Content types that are syntactically invalid or blank can be detected
and the request rejected. Types can be restricted to a specific list
containing optional wildcards ? and *.</dd>
-
+
<dt><strong><a href="../compliance.html#policylength">POLICY_LENGTH</a>
</strong>: Enforce the presence of a Content-Length</dt>
<dd>The length of responses can be specified in one of three ways, by
<pre class="prettyprint lang-config"><Location "/">
SetOutputFilter POLICY_TYPE;POLICY_LENGTH;POLICY_KEEPALIVE;POLICY_VARY;POLICY_VALIDATION; \
POLICY_CONDITIONAL;POLICY_NOCACHE;POLICY_MAXAGE;POLICY_VERSION
-
+
# content type must be present and valid, but can be anything
PolicyType enforce */*
-
+
# reject if no explicitly declared content length
PolicyLength enforce
-
+
# covered by the policy length filter
PolicyKeepalive ignore
-
+
# reject if User-Agent appears within Vary headers
PolicyVary enforce User-Agent
-
+
# we want to enforce validation
PolicyValidation enforce
-
+
# non-functional conditional responses should be rejected
PolicyConditional enforce
-
+
# no-cache responses should be rejected
PolicyNocache enforce
-
+
# maxage must be at least a day
PolicyMaxage enforce 86400
-
+
# request version can be anything
PolicyVersion ignore HTTP/1.1
</Location>
<dd>Content types that are syntactically invalid or blank can be detected
and the request rejected. Types can be restricted to a specific list
containing optional wildcards ? and *.</dd>
-
+
<dt><strong><a href="../compliance.html#policylength">POLICY_LENGTH</a>
</strong>: Enforce the presence of a Content-Length</dt>
<dd>The length of responses can be specified in one of three ways, by
<Location "/">
SetOutputFilter POLICY_TYPE;POLICY_LENGTH;POLICY_KEEPALIVE;POLICY_VARY;POLICY_VALIDATION; \
POLICY_CONDITIONAL;POLICY_NOCACHE;POLICY_MAXAGE;POLICY_VERSION
-
+
# content type must be present and valid, but can be anything
PolicyType enforce */*
-
+
# reject if no explicitly declared content length
PolicyLength enforce
-
+
# covered by the policy length filter
PolicyKeepalive ignore
-
+
# reject if User-Agent appears within Vary headers
PolicyVary enforce User-Agent
-
+
# we want to enforce validation
PolicyValidation enforce
-
+
# non-functional conditional responses should be rejected
PolicyConditional enforce
-
+
# no-cache responses should be rejected
PolicyNocache enforce
-
+
# maxage must be at least a day
PolicyMaxage enforce 86400
-
+
# request version can be anything
PolicyVersion ignore HTTP/1.1
</Location>
other request headers.</p>
<p>Note: If you need to specify custom request headers to be
- added to the forwarded request, use the
+ added to the forwarded request, use the
<code class="directive"><a href="../mod/mod_headers.html#requestheader">RequestHeader</a></code>
directive.</p>
<div class="note"><h3>Differences from the Location configuration section</h3>
- <p>A backend URL matches the configuration section if it begins with the
+ <p>A backend URL matches the configuration section if it begins with the
the <var>wildcard-url</var> string, even if the last path segment in the
- directive only matches a prefix of the backend URL. For example,
- <Proxy http://example.com/foo> matches all of
- http://example.com/foo, http://example.com/foo/bar, and
+ directive only matches a prefix of the backend URL. For example,
+ <Proxy http://example.com/foo> matches all of
+ http://example.com/foo, http://example.com/foo/bar, and
http://example.com/foobar. The matching of the final URL differs
- from the behavior of the <code class="directive"><a href="../mod/core.html#location"><Location></a></code> section, which for purposes of this note
+ from the behavior of the <code class="directive"><a href="../mod/core.html#location"><Location></a></code> section, which for purposes of this note
treats the final path component as if it ended in a slash.</p>
<p>For more control over the matching, see <code class="directive"><ProxyMatch></code>.</p>
</div>
a local virtual path; <var>url</var> is a partial URL for the
remote server and cannot include a query string.</p>
- <div class="note"><strong>Note: </strong>This directive cannot be used within a
+ <div class="note"><strong>Note: </strong>This directive cannot be used within a
<code><Directory></code> context.</div>
<div class="warning">The <code class="directive"><a href="#proxyrequests">ProxyRequests</a></code> directive should
<tr><td>stickysessionsep</td>
<td>"."</td>
<td>Sets the separation symbol in the session cookie. Some backend application servers
- do not use the '.' as the symbol. For example the Oracle Weblogic server uses
+ do not use the '.' as the symbol. For example the Oracle Weblogic server uses
'!'. The correct symbol can be set using this option. The setting of 'Off'
signifies that no symbol is used.
</td></tr>
matches, the server will substitute any parenthesized matches into the given
string and use it as a new <var>url</var>.</p>
- <div class="note"><strong>Note: </strong>This directive cannot be used within a
+ <div class="note"><strong>Note: </strong>This directive cannot be used within a
<code><Directory></code> context.</div>
-
+
<p>Suppose the local server has address <code>http://example.com/</code>;
then</p>
<var>internal-path</var>, the cookie path will be replaced with
<var>public-path</var>.
</p><p>
-In the example given with
+In the example given with
<code class="directive"><a href="#proxypassreverse">ProxyPassReverse</a></code>, the directive:
</p>
<pre class="prettyprint lang-config">ProxyPassReverseCookiePath "/" "/mirror/foo/"</pre>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1659902:1673892 (outdated) -->
+<!-- English Revision: 1659902:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 344971:1673892 (outdated) -->
+<!-- English Revision: 344971:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
header given to the proxy, and the application server can be expected
to generate self-referential headers relative to this host, so no
rewriting is necessary.</p>
-
+
<p>The main exception is when the URL path on the proxy differs from that
on the
backend. In this case, a redirect header can be rewritten relative to the
header given to the proxy, and the application server can be expected
to generate self-referential headers relative to this host, so no
rewriting is necessary.</p>
-
+
<p>The main exception is when the URL path on the proxy differs from that
on the
backend. In this case, a redirect header can be rewritten relative to the
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 669473:1649001 (outdated) -->
+<!-- English Revision: 669473:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 395228:1673892 (outdated) -->
+<!-- English Revision: 395228:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<div class="example"><h3>Single application instance, connection reuse</h3><pre class="prettyprint lang-config">ProxyPass "/myapp/" "fcgi://localhost:4000/" enablereuse=on</pre>
</div>
- <p> The following example passes the request URI as a filesystem
- path for the PHP-FPM daemon to run. The request URL is implicitly added
+ <p> The following example passes the request URI as a filesystem
+ path for the PHP-FPM daemon to run. The request URL is implicitly added
to the 2nd parameter. The hostname and port following fcgi:// are where
PHP-FPM is listening. Connection pooling is enabled.</p>
<div class="example"><h3>PHP-FPM</h3><pre class="prettyprint lang-config">ProxyPassMatch "^/myapp/.*\.php(/.*)?$" "fcgi://localhost:9000/var/www/" enablereuse=on</pre>
specified FastCGI server using reverse proxy.
This feature is available in Apache HTTP Server 2.4.10 and later. For performance
reasons, you will want to define a <a href="mod_proxy.html#workers">worker</a>
- representing the same fcgi:// backend. The benefit of this form is that it
- allows the normal mapping of URI to filename to occur in the server, and the
- local filesystem result is passed to the backend. When FastCGI is
+ representing the same fcgi:// backend. The benefit of this form is that it
+ allows the normal mapping of URI to filename to occur in the server, and the
+ local filesystem result is passed to the backend. When FastCGI is
configured this way, the server can calculate the most accurate
PATH_INFO.
</p>
SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
# Define a matching worker.
- # The part that is matched to the SetHandler is the part that
+ # The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy fcgi://localhost/ enablereuse=on max=10>
is chosen:
<dl>
<dt>first-dot</dt>
- <dd>PATH_INFO is split from the slash following the
+ <dd>PATH_INFO is split from the slash following the
<em>first</em> "." in the URL.</dd>
<dt>last-dot</dt>
- <dd>PATH_INFO is split from the slash following the
+ <dd>PATH_INFO is split from the slash following the
<em>last</em> "." in the URL.</dd>
- <dt>full</dt>
- <dd>PATH_INFO is calculated by an attempt to map the URL to the
+ <dt>full</dt>
+ <dd>PATH_INFO is calculated by an attempt to map the URL to the
local filesystem.</dd>
<dt>unescape</dt>
- <dd>PATH_INFO is the path component of the URL, unescaped /
+ <dd>PATH_INFO is the path component of the URL, unescaped /
decoded.</dd>
<dt>any other value</dt>
- <dd>PATH_INFO is the same as the path component of the URL.
+ <dd>PATH_INFO is the same as the path component of the URL.
Originally, this was the only proxy-fcgi-pathinfo option.</dd>
</dl>
</dd>
</highlight>
</example>
- <p> The following example passes the request URI as a filesystem
- path for the PHP-FPM daemon to run. The request URL is implicitly added
+ <p> The following example passes the request URI as a filesystem
+ path for the PHP-FPM daemon to run. The request URL is implicitly added
to the 2nd parameter. The hostname and port following fcgi:// are where
PHP-FPM is listening. Connection pooling is enabled.</p>
<example><title>PHP-FPM</title>
<example><title>PHP-FPM with UDS</title>
<highlight language="config">
# UDS does not currently support connection reuse
- ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php5-fpm.sock|fcgi://localhost/var/www/"
+ ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php5-fpm.sock|fcgi://localhost/var/www/"
</highlight>
</example>
specified FastCGI server using reverse proxy.
This feature is available in Apache HTTP Server 2.4.10 and later. For performance
reasons, you will want to define a <a href="mod_proxy.html#workers">worker</a>
- representing the same fcgi:// backend. The benefit of this form is that it
- allows the normal mapping of URI to filename to occur in the server, and the
- local filesystem result is passed to the backend. When FastCGI is
+ representing the same fcgi:// backend. The benefit of this form is that it
+ allows the normal mapping of URI to filename to occur in the server, and the
+ local filesystem result is passed to the backend. When FastCGI is
configured this way, the server can calculate the most accurate
PATH_INFO.
</p>
SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
# Define a matching worker.
- # The part that is matched to the SetHandler is the part that
+ # The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy fcgi://localhost/ enablereuse=on max=10>
is chosen:
<dl>
<dt>first-dot</dt>
- <dd>PATH_INFO is split from the slash following the
+ <dd>PATH_INFO is split from the slash following the
<em>first</em> "." in the URL.</dd>
<dt>last-dot</dt>
- <dd>PATH_INFO is split from the slash following the
+ <dd>PATH_INFO is split from the slash following the
<em>last</em> "." in the URL.</dd>
- <dt>full</dt>
- <dd>PATH_INFO is calculated by an attempt to map the URL to the
+ <dt>full</dt>
+ <dd>PATH_INFO is calculated by an attempt to map the URL to the
local filesystem.</dd>
<dt>unescape</dt>
- <dd>PATH_INFO is the path component of the URL, unescaped /
+ <dd>PATH_INFO is the path component of the URL, unescaped /
decoded.</dd>
<dt>any other value</dt>
- <dd>PATH_INFO is the same as the path component of the URL.
+ <dd>PATH_INFO is the same as the path component of the URL.
Originally, this was the only proxy-fcgi-pathinfo option.</dd>
</dl>
</dd>
</ul>
<p>Take care when using these. The fixes will correct certain authoring
mistakes, but risk also erroneously fixing links that were correct to start with.
-Only use them if you know you have a broken backend server.</p>
+Only use them if you know you have a broken backend server.</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
</ul>
<p>Take care when using these. The fixes will correct certain authoring
mistakes, but risk also erroneously fixing links that were correct to start with.
-Only use them if you know you have a broken backend server.</p>
+Only use them if you know you have a broken backend server.</p>
</usage>
</directivesynopsis>
</modulesynopsis>
-
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config"># Use the default header (X-Sendfile)
ProxySCGISendfile On
-
+
# Use a different header
ProxySCGISendfile X-Send-Static</pre>
</div>
<highlight language="config">
# Use the default header (X-Sendfile)
ProxySCGISendfile On
-
+
# Use a different header
ProxySCGISendfile X-Send-Static
</highlight>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_wstunnel</td></tr>
</table>
- <p>This directive instructs the server to try to create an asynchronous tunnel.
- If the current MPM does not support the necessary features, a synchronous
+ <p>This directive instructs the server to try to create an asynchronous tunnel.
+ If the current MPM does not support the necessary features, a synchronous
tunnel is used.</p>
- <div class="note"><h3>Note</h3><p>Async support is experimental and subject
+ <div class="note"><h3>Note</h3><p>Async support is experimental and subject
to change.</p></div>
</div>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_wstunnel</td></tr>
</table>
- <p>If <code class="directive">ProxyWebsocketAsync</code> is enabled, this directive
+ <p>If <code class="directive">ProxyWebsocketAsync</code> is enabled, this directive
controls how long the server synchronously waits for more data.</p>
- <div class="note"><h3>Note</h3><p>Async support is experimental and subject
+ <div class="note"><h3>Note</h3><p>Async support is experimental and subject
to change. </p></div>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy_wstunnel</td></tr>
</table>
- <p>This directive imposes a maximum amount of time for the tunnel to be
+ <p>This directive imposes a maximum amount of time for the tunnel to be
left open while idle.</p>
</div>
</contextlist>
<usage>
- <p>This directive instructs the server to try to create an asynchronous tunnel.
- If the current MPM does not support the necessary features, a synchronous
+ <p>This directive instructs the server to try to create an asynchronous tunnel.
+ If the current MPM does not support the necessary features, a synchronous
tunnel is used.</p>
- <note><title>Note</title><p>Async support is experimental and subject
+ <note><title>Note</title><p>Async support is experimental and subject
to change.</p></note>
</usage>
</directivesynopsis>
</contextlist>
<usage>
- <p>This directive imposes a maximum amount of time for the tunnel to be
+ <p>This directive imposes a maximum amount of time for the tunnel to be
left open while idle.</p>
</usage>
</directivesynopsis>
</contextlist>
<usage>
- <p>If <directive>ProxyWebsocketAsync</directive> is enabled, this directive
+ <p>If <directive>ProxyWebsocketAsync</directive> is enabled, this directive
controls how long the server synchronously waits for more data.</p>
- <note><title>Note</title><p>Async support is experimental and subject
+ <note><title>Note</title><p>Async support is experimental and subject
to change. </p></note>
</usage>
<div class="example"><h3>Example Configuration</h3><pre class="prettyprint lang-config"><Location "/downloads">
SetOutputFilter RATE_LIMIT
- SetEnv rate-limit 400
+ SetEnv rate-limit 400
</Location></pre>
</div>
<highlight language="config">
<Location "/downloads">
SetOutputFilter RATE_LIMIT
- SetEnv rate-limit 400
+ SetEnv rate-limit 400
</Location>
</highlight>
</example>
</summary>
</modulesynopsis>
-
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_rewrite</td></tr>
</table>
<p>The <code class="directive">RewriteBase</code> directive specifies the
- URL prefix to be used for per-directory (htaccess)
+ URL prefix to be used for per-directory (htaccess)
<code class="directive">RewriteRule</code> directives that substitute a relative
path.</p>
<p> This directive is <em>required</em> when you use a relative path
in a substitution in per-directory (htaccess) context unless either
of the following conditions are true:</p>
<ul>
- <li> The original request, and the substitution, are underneath the
+ <li> The original request, and the substitution, are underneath the
<code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>
- (as opposed to reachable by other means, such as
+ (as opposed to reachable by other means, such as
<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>).</li>
<li> The <em>filesystem</em> path to the directory containing the
- <code class="directive">RewriteRule</code>, suffixed by the relative
- substitution is also valid as a URL path on the server
+ <code class="directive">RewriteRule</code>, suffixed by the relative
+ substitution is also valid as a URL path on the server
(this is rare).</li>
- <li> In Apache HTTP Server 2.4.11 and later, this directive may be
- omitted when the request is mapped via
+ <li> In Apache HTTP Server 2.4.11 and later, this directive may be
+ omitted when the request is mapped via
<code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code>
or <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code>.</li>
</ul>
<p> In the example below, <code class="directive">RewriteBase</code> is necessary
to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
- since the resource was not relative to the document root. This
+ since the resource was not relative to the document root. This
misconfiguration would normally cause the server to look for an "opt"
directory under the document root.</p>
<pre class="prettyprint lang-config">DocumentRoot "/var/www/example.com"
AliasMatch "^/myapp" "/opt/myapp-1.2.3"
<Directory "/opt/myapp-1.2.3">
RewriteEngine On
- RewriteBase /myapp/
- RewriteRule ^index\.html$ welcome.html
+ RewriteBase "/myapp/"
+ RewriteRule "^index\.html$" "welcome.html"
</Directory></pre>
been determined by the server at the time
<code>REQUEST_FILENAME</code> is referenced. Otherwise,
such as when used in virtual host context, the same
- value as <code>REQUEST_URI</code>. Depending on the value of
+ value as <code>REQUEST_URI</code>. Depending on the value of
<code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code>, the
- server may have only used some leading components of the
+ server may have only used some leading components of the
<code>REQUEST_URI</code> to map the request to a file.
</dd>
so that certain conditions might not be evaluated at all.</p></li>
<li>
- <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
+ <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
can be used for look-aheads which perform
an internal (URL-based) sub-request to determine the final
value of <em>variable</em>. This can be used to access
it can impact your server's performance!</p>
<p> This flag <em>only</em> returns information about things
like access control, authentication, and authorization. This flag
- <em>does not</em> return information about the status code the
- configured handler (static file, CGI, proxy, etc.) would have
+ <em>does not</em> return information about the status code the
+ configured handler (static file, CGI, proxy, etc.) would have
returned.</p> </li>
<li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
to block unwanted hotlinking.
</p>
- <pre class="prettyprint lang-config"> RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
- RewriteRule ^/images - [F]</pre>
+ <pre class="prettyprint lang-config">RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
+RewriteRule "^/images" "-" [F]</pre>
</li>
Use this to combine rule conditions with a local OR
instead of the implicit AND. Typical example:
-<pre class="prettyprint lang-config">RewriteCond %{REMOTE_HOST} ^host1 [OR]
-RewriteCond %{REMOTE_HOST} ^host2 [OR]
-RewriteCond %{REMOTE_HOST} ^host3
+<pre class="prettyprint lang-config">RewriteCond "%{REMOTE_HOST}" "^host1" [OR]
+RewriteCond "%{REMOTE_HOST}" "^host2" [OR]
+RewriteCond "%{REMOTE_HOST}" "^host3"
RewriteRule ...some special stuff for any of these hosts...</pre>
``<code>User-Agent:</code>'' header of the request, you can
use the following: </p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} (iPhone|Blackberry|Android)
-RewriteRule ^/$ /homepage.mobile.html [L]
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_USER_AGENT}" "(iPhone|Blackberry|Android)"
+RewriteRule "^/$" "/homepage.mobile.html" [L]
-RewriteRule ^/$ /homepage.std.html [L]</pre>
+RewriteRule "^/$" "/homepage.std.html" [L]</pre>
<p>Explanation: If you use a browser which identifies itself
<p>For example, you might define a
<code class="directive">RewriteMap</code> as:</p>
- <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
+ <pre class="prettyprint lang-config">RewriteMap examplemap "txt:/path/to/file/map.txt"</pre>
<p>You would then be able to use this map in a
<code class="directive">RewriteRule</code> as follows:</p>
- <pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
+ <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>
<p>The meaning of the <em>MapTypeOptions</em> argument depends on
directory on disk but lack a trailing slash, in the expectation that
the <code class="module"><a href="../mod/mod_dir.html">mod_dir</a></code> module will issue the client with a redirect to
the canonical URL with a trailing slash.</p>
-
+
<p>When the <code class="directive"><a href="../mod/mod_dir.html#directoryslash">DirectorySlash</a></code> directive
is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
that rewrite rules are no longer ignored. This option makes it possible to
Available in Apache HTTP Server 2.4.3 and later.</p>
<div class="warning">
- <h3>Security Warning</h3>
+ <h3>Security Warning</h3>
<p>Enabling this option will make the server vulnerable to
security issues if used with rewrite rules which are not
<p>When a relative substitution is made
in directory (htaccess) context and <code class="directive"><a href="#rewritebase">RewriteBase</a></code> has not been set, this module uses some
- extended URL and filesystem context information to change the
- relative substitution back into a URL. Modules such as
+ extended URL and filesystem context information to change the
+ relative substitution back into a URL. Modules such as
<code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code> and <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code>
supply this extended context info. </p>
</dd>
<dd>Designates the location on the file-system of the resource
to be delivered to the client. Substitutions are only
- treated as a file-system path when the rule is configured in
+ treated as a file-system path when the rule is configured in
server (virtualhost) context and the first component of the
path in the substitution exists in the file-system</dd>
you specify a <em>Substitution</em> string of
<code>/www/file.html</code>, then this will be treated as a
URL-path <em>unless</em> a directory named <code>www</code>
- exists at the root or your file-system (or, in the case of
+ exists at the root or your file-system (or, in the case of
using rewrites in a <code>.htaccess</code> file, relative to
your document root), in which case it will
be treated as a file-system path. If you wish other
</tr>
<tr>
<td>B</td>
- <td>Escape non-alphanumeric characters in backreferences <em>before</em>
+ <td>Escape non-alphanumeric characters in backreferences <em>before</em>
applying the transformation. <em><a href="../rewrite/flags.html#flag_b">details ...</a></em></td>
</tr>
<tr class="odd">
<td>backrefnoplus|BNP</td>
- <td>If backreferences are being escaped, spaces should be escaped to
+ <td>If backreferences are being escaped, spaces should be escaped to
%20 instead of +. Useful when the backreference will be used in the
path component rather than the query string.<em><a href="../rewrite/flags.html#flag_bnp">details ...</a></em></td>
</tr>
</tr>
<tr class="odd">
<td>qsappend|QSA</td>
- <td>Appends any query string from the original request URL to
+ <td>Appends any query string from the original request URL to
any query string created in the rewrite target.<em><a href="../rewrite/flags.html#flag_qsa">details ...</a></em></td>
</tr>
<tr>
<p><strong>Inside per-directory configuration for
<code>/somepath</code><br />
(<code>/physical/path/to/somepath/.htaccess</code>, with
- <code>RewriteBase /somepath</code>)<br />
+ <code>RewriteBase "/somepath"</code>)<br />
for request ``<code>GET
/somepath/localpath/pathinfo</code>'':</strong><br />
</p>
directory on disk but lack a trailing slash, in the expectation that
the <module>mod_dir</module> module will issue the client with a redirect to
the canonical URL with a trailing slash.</p>
-
+
<p>When the <directive module="mod_dir">DirectorySlash</directive> directive
is set to off, the <code>AllowNoSlash</code> option can be enabled to ensure
that rewrite rules are no longer ignored. This option makes it possible to
Available in Apache HTTP Server 2.4.3 and later.</p>
<note type="warning">
- <title>Security Warning</title>
+ <title>Security Warning</title>
<p>Enabling this option will make the server vulnerable to
security issues if used with rewrite rules which are not
<p>When a relative substitution is made
in directory (htaccess) context and <directive module="mod_rewrite"
>RewriteBase</directive> has not been set, this module uses some
- extended URL and filesystem context information to change the
- relative substitution back into a URL. Modules such as
+ extended URL and filesystem context information to change the
+ relative substitution back into a URL. Modules such as
<module>mod_userdir</module> and <module>mod_alias</module>
supply this extended context info. </p>
</dd>
<directive>RewriteMap</directive> as:</p>
<highlight language="config">
- RewriteMap examplemap txt:/path/to/file/map.txt
+RewriteMap examplemap "txt:/path/to/file/map.txt"
</highlight>
<p>You would then be able to use this map in a
<directive>RewriteRule</directive> as follows:</p>
<highlight language="config">
- RewriteRule ^/ex/(.*) ${examplemap:$1}
+RewriteRule "^/ex/(.*)" "${examplemap:$1}"
</highlight>
<p>The meaning of the <em>MapTypeOptions</em> argument depends on
<usage>
<p>The <directive>RewriteBase</directive> directive specifies the
- URL prefix to be used for per-directory (htaccess)
+ URL prefix to be used for per-directory (htaccess)
<directive>RewriteRule</directive> directives that substitute a relative
path.</p>
<p> This directive is <em>required</em> when you use a relative path
in a substitution in per-directory (htaccess) context unless either
of the following conditions are true:</p>
<ul>
- <li> The original request, and the substitution, are underneath the
+ <li> The original request, and the substitution, are underneath the
<directive module="core">DocumentRoot</directive>
- (as opposed to reachable by other means, such as
+ (as opposed to reachable by other means, such as
<directive module="mod_alias">Alias</directive>).</li>
<li> The <em>filesystem</em> path to the directory containing the
- <directive>RewriteRule</directive>, suffixed by the relative
- substitution is also valid as a URL path on the server
+ <directive>RewriteRule</directive>, suffixed by the relative
+ substitution is also valid as a URL path on the server
(this is rare).</li>
- <li> In Apache HTTP Server 2.4.11 and later, this directive may be
- omitted when the request is mapped via
+ <li> In Apache HTTP Server 2.4.11 and later, this directive may be
+ omitted when the request is mapped via
<directive module="mod_alias">Alias</directive>
or <module>mod_userdir</module>.</li>
</ul>
<p> In the example below, <directive>RewriteBase</directive> is necessary
to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
- since the resource was not relative to the document root. This
+ since the resource was not relative to the document root. This
misconfiguration would normally cause the server to look for an "opt"
directory under the document root.</p>
<highlight language="config">
AliasMatch "^/myapp" "/opt/myapp-1.2.3"
<Directory "/opt/myapp-1.2.3">
RewriteEngine On
- RewriteBase /myapp/
- RewriteRule ^index\.html$ welcome.html
+ RewriteBase "/myapp/"
+ RewriteRule "^index\.html$" "welcome.html"
</Directory>
</highlight>
been determined by the server at the time
<code>REQUEST_FILENAME</code> is referenced. Otherwise,
such as when used in virtual host context, the same
- value as <code>REQUEST_URI</code>. Depending on the value of
+ value as <code>REQUEST_URI</code>. Depending on the value of
<directive module="core">AcceptPathInfo</directive>, the
- server may have only used some leading components of the
+ server may have only used some leading components of the
<code>REQUEST_URI</code> to map the request to a file.
</dd>
so that certain conditions might not be evaluated at all.</p></li>
<li>
- <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
+ <a id="LA-U" name="LA-U"><code>%{LA-U:variable}</code></a>
can be used for look-aheads which perform
an internal (URL-based) sub-request to determine the final
value of <em>variable</em>. This can be used to access
it can impact your server's performance!</p>
<p> This flag <em>only</em> returns information about things
like access control, authentication, and authorization. This flag
- <em>does not</em> return information about the status code the
- configured handler (static file, CGI, proxy, etc.) would have
+ <em>does not</em> return information about the status code the
+ configured handler (static file, CGI, proxy, etc.) would have
returned.</p> </li>
<li>'<strong>-x</strong>' (has e<strong>x</strong>ecutable
</p>
<highlight language="config">
- RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
- RewriteRule ^/images - [F]
+RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
+RewriteRule "^/images" "-" [F]
</highlight>
</li>
instead of the implicit AND. Typical example:
<highlight language="config">
-RewriteCond %{REMOTE_HOST} ^host1 [OR]
-RewriteCond %{REMOTE_HOST} ^host2 [OR]
-RewriteCond %{REMOTE_HOST} ^host3
+RewriteCond "%{REMOTE_HOST}" "^host1" [OR]
+RewriteCond "%{REMOTE_HOST}" "^host2" [OR]
+RewriteCond "%{REMOTE_HOST}" "^host3"
RewriteRule ...some special stuff for any of these hosts...
</highlight>
use the following: </p>
<highlight language="config">
-RewriteCond %{HTTP_USER_AGENT} (iPhone|Blackberry|Android)
-RewriteRule ^/$ /homepage.mobile.html [L]
+RewriteCond "%{HTTP_USER_AGENT}" "(iPhone|Blackberry|Android)"
+RewriteRule "^/$" "/homepage.mobile.html" [L]
-RewriteRule ^/$ /homepage.std.html [L]
+RewriteRule "^/$" "/homepage.std.html" [L]
</highlight>
<p>Explanation: If you use a browser which identifies itself
<dd>Designates the location on the file-system of the resource
to be delivered to the client. Substitutions are only
- treated as a file-system path when the rule is configured in
+ treated as a file-system path when the rule is configured in
server (virtualhost) context and the first component of the
path in the substitution exists in the file-system</dd>
you specify a <em>Substitution</em> string of
<code>/www/file.html</code>, then this will be treated as a
URL-path <em>unless</em> a directory named <code>www</code>
- exists at the root or your file-system (or, in the case of
+ exists at the root or your file-system (or, in the case of
using rewrites in a <code>.htaccess</code> file, relative to
your document root), in which case it will
be treated as a file-system path. If you wish other
</tr>
<tr>
<td>B</td>
- <td>Escape non-alphanumeric characters in backreferences <em>before</em>
+ <td>Escape non-alphanumeric characters in backreferences <em>before</em>
applying the transformation. <em><a
href="../rewrite/flags.html#flag_b">details ...</a></em></td>
</tr>
<tr>
<td>backrefnoplus|BNP</td>
- <td>If backreferences are being escaped, spaces should be escaped to
+ <td>If backreferences are being escaped, spaces should be escaped to
%20 instead of +. Useful when the backreference will be used in the
path component rather than the query string.<em><a
href="../rewrite/flags.html#flag_bnp">details ...</a></em></td>
</tr>
<tr>
<td>qsappend|QSA</td>
- <td>Appends any query string from the original request URL to
+ <td>Appends any query string from the original request URL to
any query string created in the rewrite target.<em><a
href="../rewrite/flags.html#flag_qsa">details ...</a></em></td>
</tr>
<p><strong>Inside per-directory configuration for
<code>/somepath</code><br />
(<code>/physical/path/to/somepath/.htaccess</code>, with
- <code>RewriteBase /somepath</code>)<br />
+ <code>RewriteBase "/somepath"</code>)<br />
for request ``<code>GET
/somepath/localpath/pathinfo</code>'':</strong><br />
</p>
<p>For example:</p>
- <pre class="prettyprint lang-config">LoadFile libexec/libxmlparse.so</pre>
+ <pre class="prettyprint lang-config">LoadFile "libexec/libxmlparse.so"</pre>
<code>module</code> in the file, and is listed as the <a href="module-dict.html#ModuleIdentifier">Module Identifier</a>
in the module documentation. Example:</p>
- <pre class="prettyprint lang-config">LoadModule status_module modules/mod_status.so</pre>
+ <pre class="prettyprint lang-config">LoadModule status_module "modules/mod_status.so"</pre>
<p>loads the named module from the modules subdirectory of the
<a href="../ko/mod/mod_so.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
<a href="../tr/mod/mod_so.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
</div>
+<div class="outofdate">Cette traduction peut être périmée. Vérifiez la version
+ anglaise pour les changements récents.</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Chargement de modules ou de code exécutable au cours du
démarrage ou du redémarrage du serveur</td></tr>
<tr><th><a href="module-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
<a href="../ko/mod/mod_so.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
<a href="../tr/mod/mod_so.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
</div>
+<div class="outofdate">この日本語訳はすでに古くなっている
+ 可能性があります。
+ 最近更新された内容を見るには英語版をご覧下さい。
+ </div>
<table class="module"><tr><th><a href="module-dict.html#Description">説明:</a></th><td>起動時や再起動時に実行コードとモジュールをサーバにロードする
</td></tr>
<tr><th><a href="module-dict.html#Status">ステータス:</a></th><td>Extension</td></tr>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision : 1433861 -->
+<!-- English Revision: 1433861:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 1433861 -->
+<!-- English Revision: 1433861:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 420990:1433861 (outdated) -->
+<!-- English Revision: 420990:1673932 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<variants>
<variant>en</variant>
- <variant>fr</variant>
- <variant>ja</variant>
+ <variant outdated="yes">fr</variant>
+ <variant outdated="yes">ja</variant>
<variant outdated="yes">ko</variant>
<variant outdated="yes">tr</variant>
</variants>
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1174747:1433861 (outdated) -->
+<!-- English Revision: 1174747:1673932 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
the <a href="../expr.html#functions">ap_expr documentation</a>.</p>
<p>The <em>expression</em> is parsed into an internal machine
-representation when the configuration is loaded, and then evaluated
-during request processing. In .htaccess context, the <em>expression</em> is
-both parsed and executed each time the .htaccess file is encountered during
+representation when the configuration is loaded, and then evaluated
+during request processing. In .htaccess context, the <em>expression</em> is
+both parsed and executed each time the .htaccess file is encountered during
request processing.</p>
<div class="example"><h3>Example</h3><pre class="prettyprint lang-config">SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)-/ \
the <a href="../expr.html#functions">ap_expr documentation</a>.</p>
<p>The <em>expression</em> is parsed into an internal machine
-representation when the configuration is loaded, and then evaluated
-during request processing. In .htaccess context, the <em>expression</em> is
-both parsed and executed each time the .htaccess file is encountered during
+representation when the configuration is loaded, and then evaluated
+during request processing. In .htaccess context, the <em>expression</em> is
+both parsed and executed each time the .htaccess file is encountered during
request processing.</p>
<example><title>Example</title>
</section>
</modulesynopsis>
-
when regular expressions are used, as illustrated in the following example: </p>
<div class="example"><h3>Example of using backreferences and captures</h3><pre class="prettyprint lang-config"><Location "/">
AddOutputFilterByType SUBSTITUTE text/html
- # "foo=k,bar=k" -> "foo/bar=k"
+ # "foo=k,bar=k" -> "foo/bar=k"
Substitute "s|foo=(\w+),bar=\1|foo/bar=$1"
</Location></pre>
</div>
<highlight language="config">
<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
- # "foo=k,bar=k" -> "foo/bar=k"
+ # "foo=k,bar=k" -> "foo/bar=k"
Substitute "s|foo=(\w+),bar=\1|foo/bar=$1"
</Location>
</highlight>
syslog(1). The facility is effectively global, and if it is changed
in individual virtual hosts, the final facility specified affects the
entire server.</p>
-
+
<pre class="prettyprint lang-config">ErrorLog syslog:user</pre>
syslog(1). The facility is effectively global, and if it is changed
in individual virtual hosts, the final facility specified affects the
entire server.</p>
-
+
<highlight language="config">
ErrorLog syslog:user
</highlight>
<p>The example request would come from
<code>/usr/local/apache/vhosts/example.com/d/o/m/ain/directory/file.html</code>.</p>
-<p> A very common request by users is the ability to point multiple domains to multiple
-document roots without having to worry about the length or number of parts of the
+<p> A very common request by users is the ability to point multiple domains to multiple
+document roots without having to worry about the length or number of parts of the
hostname being requested. If the requested hostname is <code>sub.www.domain.example.com</code>
instead of simply <code>www.domain.example.com</code>, then using %3+ will result in the document
root being <code>/usr/local/apache/vhosts/domain.example.com/...</code> instead of the
-intended <code>example.com</code> directory. In such cases, it can be beneficial to use
-the combination <code>%-2.0.%-1.0</code>, which will always yield the domain name and the
-tld, for example <code>example.com</code> regardless of the number of subdomains appended
-to the hostname. As such, one can make a configuration that will direct all first, second
+intended <code>example.com</code> directory. In such cases, it can be beneficial to use
+the combination <code>%-2.0.%-1.0</code>, which will always yield the domain name and the
+tld, for example <code>example.com</code> regardless of the number of subdomains appended
+to the hostname. As such, one can make a configuration that will direct all first, second
or third level subdomains to the same directory:
</p>
<pre class="prettyprint lang-config">VirtualDocumentRoot "/usr/local/apache/vhosts/%-2.0.%-1.0"</pre>
cannot be used in the same context as <code class="directive"><a href="#virtualdocumentrootip">VirtualDocumentRootIP</a></code>.</p>
<div class="warning"><h3>Note</h3>
-<code class="directive">VirtualDocumentRoot</code> will override any <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directives you may have put in the same
-context or child contexts. Putting a <code class="directive">VirtualDocumentRoot</code>
-in the global server scope will effectively override <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directives in any virtual hosts defined later
-on, unless you set <code class="directive">VirtualDocumentRoot</code> to <code>None</code>
+<code class="directive">VirtualDocumentRoot</code> will override any <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directives you may have put in the same
+context or child contexts. Putting a <code class="directive">VirtualDocumentRoot</code>
+in the global server scope will effectively override <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directives in any virtual hosts defined later
+on, unless you set <code class="directive">VirtualDocumentRoot</code> to <code>None</code>
in each virtual host.
</div>
<p>The example request would come from
<code>/usr/local/apache/vhosts/example.com/d/o/m/ain/directory/file.html</code>.</p>
-<p> A very common request by users is the ability to point multiple domains to multiple
-document roots without having to worry about the length or number of parts of the
+<p> A very common request by users is the ability to point multiple domains to multiple
+document roots without having to worry about the length or number of parts of the
hostname being requested. If the requested hostname is <code>sub.www.domain.example.com</code>
instead of simply <code>www.domain.example.com</code>, then using %3+ will result in the document
root being <code>/usr/local/apache/vhosts/domain.example.com/...</code> instead of the
-intended <code>example.com</code> directory. In such cases, it can be beneficial to use
-the combination <code>%-2.0.%-1.0</code>, which will always yield the domain name and the
-tld, for example <code>example.com</code> regardless of the number of subdomains appended
-to the hostname. As such, one can make a configuration that will direct all first, second
+intended <code>example.com</code> directory. In such cases, it can be beneficial to use
+the combination <code>%-2.0.%-1.0</code>, which will always yield the domain name and the
+tld, for example <code>example.com</code> regardless of the number of subdomains appended
+to the hostname. As such, one can make a configuration that will direct all first, second
or third level subdomains to the same directory:
</p>
<highlight language="config">
<note type="warning"><title>Note</title>
<directive>VirtualDocumentRoot</directive> will override any <directive
-module="core">DocumentRoot</directive> directives you may have put in the same
-context or child contexts. Putting a <directive>VirtualDocumentRoot</directive>
-in the global server scope will effectively override <directive
-module="core">DocumentRoot</directive> directives in any virtual hosts defined later
-on, unless you set <directive>VirtualDocumentRoot</directive> to <code>None</code>
+module="core">DocumentRoot</directive> directives you may have put in the same
+context or child contexts. Putting a <directive>VirtualDocumentRoot</directive>
+in the global server scope will effectively override <directive
+module="core">DocumentRoot</directive> directives in any virtual hosts defined later
+on, unless you set <directive>VirtualDocumentRoot</directive> to <code>None</code>
in each virtual host.
</note>
</directivesynopsis>
</modulesynopsis>
-
</directivesynopsis>
</modulesynopsis>
-
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">How much compression do we apply to the output</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">Places the compression ratio in a note for logging</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">How much memory should be used by zlib for compression</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">How much compression do we apply to the output</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">Places the compression ratio in a note for logging</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">How much memory should be used by zlib for compression</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">How much compression do we apply to the output</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">Places the compression ratio in a note for logging</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">How much memory should be used by zlib for compression</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">出力に対して行なう圧縮の程度</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">ロギング用に圧縮比をメモに追加</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">zlib が圧縮に使うメモリのレベルを指定</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Ãâ·ÂÀ» ¾î´ÀÁ¤µµ ¾ÐÃàÇϴ°¡</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">¾ÐÃà·üÀ» ·Î±×¿¡ ±â·ÏÇÑ´Ù</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">zlibÀÌ ¾ÐÃàÇÒ¶§ »ç¿ëÇÏ´Â ¸Þ¸ð¸®·®</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sk</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">How much compression do we apply to the output</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sk</td><td>E</td></tr><tr><td class="descr" colspan="4">Places the compression ratio in a note for logging</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>skdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>skdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>skdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>skdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sk</td><td>E</td></tr><tr><td class="descr" colspan="4">How much memory should be used by zlib for compression</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflatecompressionlevel">DeflateCompressionLevel <var>value</var></a></td><td></td><td>sv</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">How much compression do we apply to the output</td></tr>
<tr><td><a href="mod_deflate.html#deflatefilternote">DeflateFilterNote [<var>type</var>] <var>notename</var></a></td><td></td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">Places the compression ratio in a note for logging</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflatelimitrequestbody">DeflateInflateLimitRequestBody<var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum size of inflated request bodies</td></tr>
-<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
+<tr><td><a href="mod_deflate.html#deflateinflateratioburst">DeflateInflateRatioBurst <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr><td class="descr" colspan="4">Maximum number of times the inflation ratio for request bodies
can be crossed</td></tr>
<tr class="odd"><td><a href="mod_deflate.html#deflateinflateratiolimit">DeflateInflateRatioLimit <var>value</var></a></td><td></td><td>svdh</td><td>E</td></tr><tr class="odd"><td class="descr" colspan="4">Maximum inflation ratio for request bodies</td></tr>
<tr><td><a href="mod_deflate.html#deflatememlevel">DeflateMemLevel <var>value</var></a></td><td> 9 </td><td>sv</td><td>E</td></tr><tr><td class="descr" colspan="4">How much memory should be used by zlib for compression</td></tr>
<h2><a name="down" id="down">Downloading Apache for Windows</a></h2>
- <p>The Apache HTTP Server Project itself does not provide binary releases of
- software, only source code. Individual committers <em>may</em> provide
+ <p>The Apache HTTP Server Project itself does not provide binary releases of
+ software, only source code. Individual committers <em>may</em> provide
binary packages as a convenience, but it is not a release deliverable.</p>
<p>If you cannot compile the Apache HTTP Server
yourself, you can obtain a binary package from numerous binary distributions
is used in URLs, you can use something like:</p>
<pre class="prettyprint lang-config">RewriteEngine On
-RewriteMap lowercase int:tolower
-RewriteCond %{REQUEST_URI} [A-Z]
-RewriteRule (.*) ${lowercase:$1} [R,L]</pre>
+RewriteMap lowercase "int:tolower"
+RewriteCond "%{REQUEST_URI}" "[A-Z]"
+RewriteRule "(.*)" "${lowercase:$1}" [R,L]</pre>
</li>
<li><p>When running, Apache needs write access only to the logs
Programs. Change to the folder to which you installed Apache, type
the command <code>httpd.exe</code>, and read the error message. Then
change to the logs folder, and review the <code>error.log</code>
- file for configuration mistakes. Assuming httpd was installed into
- <code>C:\Program Files\Apache Software Foundation\Apache2.5\</code>,
+ file for configuration mistakes. Assuming httpd was installed into
+ <code>C:\Program Files\Apache Software Foundation\Apache2.5\</code>,
you can do the following:</p>
<div class="example"><p><code>
<h2><a name="tuning" id="tuning">Windows Tuning</a></h2>
<ul>
- <li><p>If more than a few dozen piped loggers are used on an operating system
+ <li><p>If more than a few dozen piped loggers are used on an operating system
instance, scaling up the "desktop heap" is often necessary. For
more detailed information, refer to the <a href="../logs.html#piped">piped logging</a> documentation.</p></li>
</ul>
<section id="down">
<title>Downloading Apache for Windows</title>
- <p>The Apache HTTP Server Project itself does not provide binary releases of
- software, only source code. Individual committers <em>may</em> provide
+ <p>The Apache HTTP Server Project itself does not provide binary releases of
+ software, only source code. Individual committers <em>may</em> provide
binary packages as a convenience, but it is not a release deliverable.</p>
<p>If you cannot compile the Apache HTTP Server
yourself, you can obtain a binary package from numerous binary distributions
</ul>
</section>
-
+
<section id="cust">
<title>Customizing Apache for Windows</title>
<highlight language="config">
RewriteEngine On
-RewriteMap lowercase int:tolower
-RewriteCond %{REQUEST_URI} [A-Z]
-RewriteRule (.*) ${lowercase:$1} [R,L]
+RewriteMap lowercase "int:tolower"
+RewriteCond "%{REQUEST_URI}" "[A-Z]"
+RewriteRule "(.*)" "${lowercase:$1}" [R,L]
</highlight></li>
<li><p>When running, Apache needs write access only to the logs
Programs. Change to the folder to which you installed Apache, type
the command <code>httpd.exe</code>, and read the error message. Then
change to the logs folder, and review the <code>error.log</code>
- file for configuration mistakes. Assuming httpd was installed into
- <code>C:\Program Files\Apache Software Foundation\Apache2.&httpd.minor;\</code>,
+ file for configuration mistakes. Assuming httpd was installed into
+ <code>C:\Program Files\Apache Software Foundation\Apache2.&httpd.minor;\</code>,
you can do the following:</p>
<example>
<section id="tuning">
<title>Windows Tuning</title>
<ul>
- <li><p>If more than a few dozen piped loggers are used on an operating system
+ <li><p>If more than a few dozen piped loggers are used on an operating system
instance, scaling up the "desktop heap" is often necessary. For
more detailed information, refer to the <a href="../logs.html#piped"
>piped logging</a> documentation.</p></li>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ - [F,NC]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "-" [F,NC]</pre>
<p>In this second example, instead of failing the request, we display
an alternate image instead.</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "/images/go-away.png" [R,NC]</pre>
<p>In the third example, we redirect the request to an image on some
other site.</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "http://other.example.com/image.gif" [R,NC]</pre>
<p>Of these techniques, the last two tend to be the most effective
range, if you are trying to block that user agent only from the
particular source.</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
-RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9]
-RewriteRule ^/secret/files/ - [F]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_USER_AGENT}" "^NameOfBadRobot"
+RewriteCond "%{REMOTE_ADDR}" "=123\.45\.67\.[8-9]"
+RewriteRule "^/secret/files/" "-" [F]</pre>
</dd>
<dd>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
-RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^ - [F]</pre>
+RewriteMap hosts-deny "txt:/path/to/hosts.deny"
+RewriteCond "${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}" "!=NOT-FOUND" [OR]
+RewriteCond "${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}" "!=NOT-FOUND"
+RewriteRule "^" "-" [F]</pre>
<div class="example"><p><code>
<p>The following ruleset uses a map file to associate each Referer
with a redirection target.</p>
-<pre class="prettyprint lang-config">RewriteMap deflector txt:/path/to/deflector.map
+<pre class="prettyprint lang-config">RewriteMap deflector "txt:/path/to/deflector.map"
-RewriteCond %{HTTP_REFERER} !=""
-RewriteCond ${deflector:%{HTTP_REFERER}} =-
-RewriteRule ^ %{HTTP_REFERER} [R,L]
+RewriteCond "%{HTTP_REFERER}" !=""
+RewriteCond "${deflector:%{HTTP_REFERER}}" =-
+RewriteRule "^" "%{HTTP_REFERER}" [R,L]
-RewriteCond %{HTTP_REFERER} !=""
-RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]</pre>
+RewriteCond "%{HTTP_REFERER}" !=""
+RewriteCond "${deflector:%{HTTP_REFERER}|NOT-FOUND}" "!=NOT-FOUND"
+RewriteRule "^" "${deflector:%{HTTP_REFERER}}" [R,L]</pre>
<p>The map file lists redirection targets for each referer, or, if
<!-- TODO: Add discussion here of why we have !^$ in there. -->
<highlight language="config">
-RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ - [F,NC]
+RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "-" [F,NC]
</highlight>
<p>In this second example, instead of failing the request, we display
an alternate image instead.</p>
<highlight language="config">
-RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ /images/go-away.png [R,NC]
+RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "/images/go-away.png" [R,NC]
</highlight>
<p>In the third example, we redirect the request to an image on some
other site.</p>
<highlight language="config">
-RewriteCond %{HTTP_REFERER} !^$
-RewriteCond %{HTTP_REFERER} !www.example.com [NC]
-RewriteRule \.(gif|jpg|png)$ http://other.example.com/image.gif [R,NC]
+RewriteCond "%{HTTP_REFERER}" "!^$"
+RewriteCond "%{HTTP_REFERER}" "!www.example.com" [NC]
+RewriteRule "\.(gif|jpg|png)$" "http://other.example.com/image.gif" [R,NC]
</highlight>
<p>Of these techniques, the last two tend to be the most effective
particular source.</p>
<highlight language="config">
-RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot
-RewriteCond %{REMOTE_ADDR} =123\.45\.67\.[8-9]
-RewriteRule ^/secret/files/ - [F]
+RewriteCond "%{HTTP_USER_AGENT}" "^NameOfBadRobot"
+RewriteCond "%{REMOTE_ADDR}" "=123\.45\.67\.[8-9]"
+RewriteRule "^/secret/files/" "-" [F]
</highlight>
</dd>
<dd>
<highlight language="config">
RewriteEngine on
-RewriteMap hosts-deny txt:/path/to/hosts.deny
-RewriteCond ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
-RewriteCond ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^ - [F]
+RewriteMap hosts-deny "txt:/path/to/hosts.deny"
+RewriteCond "${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}" "!=NOT-FOUND" [OR]
+RewriteCond "${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}" "!=NOT-FOUND"
+RewriteRule "^" "-" [F]
</highlight>
<example>
with a redirection target.</p>
<highlight language="config">
-RewriteMap deflector txt:/path/to/deflector.map
+RewriteMap deflector "txt:/path/to/deflector.map"
-RewriteCond %{HTTP_REFERER} !=""
-RewriteCond ${deflector:%{HTTP_REFERER}} =-
-RewriteRule ^ %{HTTP_REFERER} [R,L]
+RewriteCond "%{HTTP_REFERER}" !=""
+RewriteCond "${deflector:%{HTTP_REFERER}}" =-
+RewriteRule "^" "%{HTTP_REFERER}" [R,L]
-RewriteCond %{HTTP_REFERER} !=""
-RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
-RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]
+RewriteCond "%{HTTP_REFERER}" !=""
+RewriteCond "${deflector:%{HTTP_REFERER}|NOT-FOUND}" "!=NOT-FOUND"
+RewriteRule "^" "${deflector:%{HTTP_REFERER}}" [R,L]
</highlight>
<p>The map file lists redirection targets for each referer, or, if
a user has no entry in the map:</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts
-RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2</pre>
+RewriteMap users-to-hosts "txt:/path/to/map.users-to-hosts"
+RewriteRule "^/u/([^/]+)/?(.*)" "http://${users-to-hosts:$1|server0}/u/$1/$2"</pre>
</dd>
</dl>
This is done via the following ruleset:
<pre class="prettyprint lang-config"># This example is valid in per-directory context only
-RewriteCond %{REQUEST_URI} !-U
-RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L]</pre>
+RewriteCond "%{REQUEST_URI}" !-U
+RewriteRule "^(.+)\.html$" "/regenerate_page.cgi" [PT,L]</pre>
<p>The <code>-U</code> operator determines whether the test string
to accomplish this.</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteMap lb rnd:/path/to/serverlist.txt
-RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L]</pre>
+RewriteMap lb "rnd:/path/to/serverlist.txt"
+RewriteRule "^/(.*)" "http://${lb:servers}/$1" [P,L]</pre>
<p><code>serverlist.txt</code> will contain a list of the servers:</p>
into the above layout.</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3</pre>
+RewriteRule "^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*)" "/home/<strong>$2</strong>/$1/public_html$3"</pre>
</dd>
</dl>
do time-dependent redirects:</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700
-RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900
-RewriteRule ^foo\.html$ foo.day.html [L]
-RewriteRule ^foo\.html$ foo.night.html</pre>
+RewriteCond "%{TIME_HOUR}%{TIME_MIN}" >0700
+RewriteCond "%{TIME_HOUR}%{TIME_MIN}" <1900
+RewriteRule "^foo\.html$" "foo.day.html" [L]
+RewriteRule "^foo\.html$" "foo.night.html"</pre>
<p>This provides the content of <code>foo.day.html</code>
<p>Use the [E] flag to set an environment variable.</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^/horse/(.*) /pony/$1 [E=<strong>rewritten:1</strong>]</pre>
+RewriteRule "^/horse/(.*)" "/pony/$1" [E=<strong>rewritten:1</strong>]</pre>
<p>Later in your ruleset you might check for this environment
variable using a RewriteCond:</p>
-<pre class="prettyprint lang-config">RewriteCond %{ENV:rewritten} =1</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{ENV:rewritten}" =1</pre>
<p>Note that environment variables do not survive an external
<highlight language="config">
RewriteEngine on
-RewriteMap users-to-hosts txt:/path/to/map.users-to-hosts
-RewriteRule ^/u/([^/]+)/?(.*) http://${users-to-hosts:$1|server0}/u/$1/$2
+RewriteMap users-to-hosts "txt:/path/to/map.users-to-hosts"
+RewriteRule "^/u/([^/]+)/?(.*)" "http://${users-to-hosts:$1|server0}/u/$1/$2"
</highlight>
</dd>
</dl>
<highlight language="config">
# This example is valid in per-directory context only
-RewriteCond %{REQUEST_URI} !-U
-RewriteRule ^(.+)\.html$ /regenerate_page.cgi [PT,L]
+RewriteCond "%{REQUEST_URI}" !-U
+RewriteRule "^(.+)\.html$" "/regenerate_page.cgi" [PT,L]
</highlight>
<p>The <code>-U</code> operator determines whether the test string
<highlight language="config">
RewriteEngine on
-RewriteMap lb rnd:/path/to/serverlist.txt
-RewriteRule ^/(.*) http://${lb:servers}/$1 [P,L]
+RewriteMap lb "rnd:/path/to/serverlist.txt"
+RewriteRule "^/(.*)" "http://${lb:servers}/$1" [P,L]
</highlight>
<p><code>serverlist.txt</code> will contain a list of the servers:</p>
<highlight language="config">
RewriteEngine on
-RewriteRule ^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*) /home/<strong>$2</strong>/$1/public_html$3
+RewriteRule "^/~(<strong>([a-z])</strong>[a-z0-9]+)(.*)" "/home/<strong>$2</strong>/$1/public_html$3"
</highlight>
</dd>
</dl>
<highlight language="config">
RewriteEngine on
-RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700
-RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900
-RewriteRule ^foo\.html$ foo.day.html [L]
-RewriteRule ^foo\.html$ foo.night.html
+RewriteCond "%{TIME_HOUR}%{TIME_MIN}" >0700
+RewriteCond "%{TIME_HOUR}%{TIME_MIN}" <1900
+RewriteRule "^foo\.html$" "foo.day.html" [L]
+RewriteRule "^foo\.html$" "foo.night.html"
</highlight>
<p>This provides the content of <code>foo.day.html</code>
<highlight language="config">
RewriteEngine on
-RewriteRule ^/horse/(.*) /pony/$1 [E=<strong>rewritten:1</strong>]
+RewriteRule "^/horse/(.*)" "/pony/$1" [E=<strong>rewritten:1</strong>]
</highlight>
<p>Later in your ruleset you might check for this environment
variable using a RewriteCond:</p>
<highlight language="config">
-RewriteCond %{ENV:rewritten} =1
+RewriteCond "%{ENV:rewritten}" =1
</highlight>
<p>Note that environment variables do not survive an external
<p>Each flag (with a few exceptions) has a short form, such as
-<code>CO</code>, as well as a longer form, such as <code>cookie</code>.
+<code>CO</code>, as well as a longer form, such as <code>cookie</code>.
While it is most common to use
the short form, it is recommended that you familiarize yourself with the
long form, so that you remember what each flag is supposed to do.
<h2><a name="flag_b" id="flag_b">B (escape backreferences)</a></h2>
<p>The [B] flag instructs <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to escape non-alphanumeric
characters before applying the transformation.</p>
-<p>In 2.4.10 and later, you can limit the escaping to specific characters
-in backreferences by listing them: <code>[B=#?;]</code>. Note: The space
-character can be used in the list of characters to escape, but it cannot be
+<p>In 2.4.10 and later, you can limit the escaping to specific characters
+in backreferences by listing them: <code>[B=#?;]</code>. Note: The space
+character can be used in the list of characters to escape, but it cannot be
the last character in the list.</p>
<p><code>mod_rewrite</code> has to unescape URLs before mapping them,
Using the B flag, non-alphanumeric characters in backreferences
will be escaped. For example, consider the rule:</p>
-<pre class="prettyprint lang-config">RewriteRule ^search/(.*)$ /search.php?term=$1</pre>
+<pre class="prettyprint lang-config">RewriteRule "^search/(.*)$" "/search.php?term=$1"</pre>
<p>Given a search term of 'x & y/z', a browser will encode it as
<div class="section">
<h2><a name="flag_bnp" id="flag_bnp">BNP|backrefnoplus (don't escape space to +)</a></h2>
<p>The [BNP] flag instructs <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to escape the space character
-in a backreference to %20 rather than '+'. Useful when the backreference
+in a backreference to %20 rather than '+'. Useful when the backreference
will be used in the path component rather than the query string.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<p>Consider this example:</p>
<pre class="prettyprint lang-config">RewriteEngine On
-RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/]</pre>
+RewriteRule "^/index\.html" "-" [CO=frontdoor:yes:.example.com:1440:/]</pre>
<p>In the example give, the rule doesn't rewrite the request.
environment variable is used to exclude those requests from the access
log.</p>
-<pre class="prettyprint lang-config">RewriteRule \.(png|gif|jpg)$ - [E=image:1]
-CustomLog logs/access_log combined env=!image</pre>
+<pre class="prettyprint lang-config">RewriteRule "\.(png|gif|jpg)$" "-" [E=image:1]
+CustomLog logs/access_log combined env=!image</pre>
<p>Note that this same effect can be obtained using <code class="directive"><a href="../mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>. This technique is offered as
an example, not as a recommendation.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
-<h2><a name="flag_end" id="flag_end">END</a></h2>
+<h2><a name="flag_end" id="flag_end">END</a></h2>
<p>Using the [END] flag terminates not only the current round of rewrite
processing (like [L]) but also prevents any subsequent rewrite
processing from occurring in per-directory (htaccess) context.</p>
<p>The following rule will forbid <code>.exe</code> files from being
downloaded from your server.</p>
-<pre class="prettyprint lang-config">RewriteRule \.exe - [F]</pre>
+<pre class="prettyprint lang-config">RewriteRule "\.exe" "-" [F]</pre>
<p>This example uses the "-" syntax for the rewrite target, which means
<p>As with the [F] flag, you will typically use the "-" syntax for the
rewrite target when using the [G] flag:</p>
-<pre class="prettyprint lang-config">RewriteRule oldproduct - [G,NC]</pre>
+<pre class="prettyprint lang-config">RewriteRule "oldproduct" "-" [G,NC]</pre>
<p>When using [G], an [L] is implied - that is, the response is returned
handler. For example, one might use this to force all files without a
file extension to be parsed by the php handler:</p>
-<pre class="prettyprint lang-config">RewriteRule !\. - [H=application/x-httpd-php]</pre>
+<pre class="prettyprint lang-config">RewriteRule "!\." "-" [H=application/x-httpd-php]</pre>
<p>
<code>.php</code> files to be <em>displayed</em> by <code>mod_php</code>
if they are requested with the <code>.phps</code> extension:</p>
-<pre class="prettyprint lang-config">RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^(/source/.+\.php)s$" "$1" [H=application/x-httpd-php-source]</pre>
<p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will
argument to <code>index.php</code>, however, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> ensures that if the request
is already for <code>index.php</code>, the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> will be skipped.</p>
-<pre class="prettyprint lang-config">RewriteBase /
-RewriteCond %{REQUEST_URI} !=/index.php
-RewriteRule ^(.*) /index.php?req=$1 [L,PT]</pre>
+<pre class="prettyprint lang-config">RewriteBase "/"
+RewriteCond "%{REQUEST_URI}" !=/index.php
+RewriteRule "^(.*)" "/index.php?req=$1" [L,PT]</pre>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
will replace A with B everywhere in a request, and will continue doing
so until there are no more As to be replaced.
</p>
-<pre class="prettyprint lang-config">RewriteRule (.*)A(.*) $1B$2 [N]</pre>
+<pre class="prettyprint lang-config">RewriteRule "(.*)A(.*)" "$1B$2" [N]</pre>
<p>You can think of this as a <code>while</code> loop: While this
pattern still matches (i.e., while the URI still contains an
<code>A</code> with a <code>B</code>).</p>
<p>In 2.5.0 and later, this module returns an error after 10,000 iterations to
-protect against unintended looping. An alternative maximum number of
+protect against unintended looping. An alternative maximum number of
iterations can be specified by adding to the N flag. </p>
<pre class="prettyprint lang-config"># Be willing to replace 1 character in each pass of the loop
-RewriteRule (.+)[><;]$ $1 [N=32000]
+RewriteRule "(.+)[><;]$" "$1" [N=32000]
# ... or, give up if after 10 loops
-RewriteRule (.+)[><;]$ $1 [N=10]</pre>
+RewriteRule "(.+)[><;]$" "$1" [N=10]</pre>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<code>.jpg</code> and <code>.JPG</code> files are both acceptable, for
example.</p>
-<pre class="prettyprint lang-config">RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]</pre>
+<pre class="prettyprint lang-config">RewriteRule "(.*\.(jpg|gif|png))$" "http://images.example.com$1" [P,NC]</pre>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
equivalent. Using the [NE] flag prevents that from happening.
</p>
-<pre class="prettyprint lang-config">RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/anchor/(.+)" "/bigpage.html#$1" [NE,R]</pre>
<p>
example, if you wanted all image requests to be handled by a back-end
image server, you might do something like the following:</p>
-<pre class="prettyprint lang-config">RewriteRule /(.*)\.(jpg|gif|png)$ http://images.example.com/$1.$2 [P]</pre>
+<pre class="prettyprint lang-config">RewriteRule "/(.*)\.(jpg|gif|png)$" "http://images.example.com/$1.$2" [P]</pre>
<p>Use of the [P] flag implies [L] - that is, the request is immediately
</p>
<pre class="prettyprint lang-config">Alias "/icons" "/usr/local/apache/icons"
-RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT]</pre>
+RewriteRule "/pics/(.+)\.jpg$" "/icons/$1.gif" [PT]</pre>
<p>
<p>Consider the following rule:</p>
-<pre class="prettyprint lang-config">RewriteRule /pages/(.+) /page.php?page=$1 [QSA]</pre>
+<pre class="prettyprint lang-config">RewriteRule "/pages/(.+)" "/page.php?page=$1" [QSA]</pre>
<p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be
<em>Any</em> valid HTTP response status code may be specified,
using the syntax [R=305], with a 302 status code being used by
default if none is specified. The status code specified need not
-necessarily be a redirect (3xx) status code. However,
+necessarily be a redirect (3xx) status code. However,
if a status code is outside the redirect range (300-399) then the
substitution string is dropped entirely, and rewriting is stopped as if
the <code>L</code> were used.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="flag_s" id="flag_s">S|skip</a></h2>
-<p>The [S] flag is used to skip rules that you don't want to run. The
-syntax of the skip flag is [S=<em>N</em>], where <em>N</em> signifies
+<p>The [S] flag is used to skip rules that you don't want to run. The
+syntax of the skip flag is [S=<em>N</em>], where <em>N</em> signifies
the number of rules to skip (provided the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">
RewriteRule</a></code> and any preceding <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">
-RewriteCond</a></code> directives match). This can be thought of as a
-<code>goto</code> statement in your rewrite ruleset. In the following
+RewriteCond</a></code> directives match). This can be thought of as a
+<code>goto</code> statement in your rewrite ruleset. In the following
example, we only want to run the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">
-RewriteRule</a></code> if the requested URI doesn't correspond with an
+RewriteRule</a></code> if the requested URI doesn't correspond with an
actual file.</p>
<pre class="prettyprint lang-config"># Is the request for a non-existent file?
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
# If so, skip these two RewriteRules
-RewriteRule .? - [S=2]
+RewriteRule ".?" "-" [S=2]
-RewriteRule (.*\.gif) images.php?$1
-RewriteRule (.*\.html) docs.php?$1</pre>
+RewriteRule "(.*\.gif)" "images.php?$1"
+RewriteRule "(.*\.html)" "docs.php?$1"</pre>
<p>This technique is useful because a <code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> only applies to the
the then-clause becomes <code>skip=N</code>, where N is the
number of rules in the else-clause:</p>
<pre class="prettyprint lang-config"># Does the file exist?
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
-RewriteRule .? - [S=3]
+RewriteRule ".?" "-" [S=3]
# IF the file exists, then:
- RewriteRule (.*\.gif) images.php?$1
- RewriteRule (.*\.html) docs.php?$1
+ RewriteRule "(.*\.gif)" "images.php?$1"
+ RewriteRule "(.*\.html)" "docs.php?$1"
# Skip past the "else" stanza.
- RewriteRule .? - [S=1]
+ RewriteRule ".?" "-" [S=1]
# ELSE...
- RewriteRule (.*) 404.php?file=$1
+ RewriteRule "(.*)" "404.php?file=$1"
# END</pre>
source code as plain text, if requested in a particular way:</p>
<pre class="prettyprint lang-config"># Serve .pl files as plain text
-RewriteRule \.pl$ - [T=text/plain]</pre>
+RewriteRule "\.pl$" "-" [T=text/plain]</pre>
<p>Or, perhaps, if you have a camera that produces jpeg images without
correct MIME type by virtue of their file names:</p>
<pre class="prettyprint lang-config"># Files with 'IMG' in the name are jpg images.
-RewriteRule IMG - [T=image/jpg]</pre>
+RewriteRule "IMG" "-" [T=image/jpg]</pre>
<p>Please note that this is a trivial example, and could be better done
will be escaped. For example, consider the rule:</p>
<highlight language="config">
-RewriteRule ^search/(.*)$ /search.php?term=$1
+RewriteRule "^search/(.*)$" "/search.php?term=$1"
</highlight>
<p>Given a search term of 'x & y/z', a browser will encode it as
<highlight language="config">
RewriteEngine On
-RewriteRule ^/index\.html - [CO=frontdoor:yes:.example.com:1440:/]
+RewriteRule "^/index\.html" "-" [CO=frontdoor:yes:.example.com:1440:/]
</highlight>
<p>In the example give, the rule doesn't rewrite the request.
log.</p>
<highlight language="config">
-RewriteRule \.(png|gif|jpg)$ - [E=image:1]
-CustomLog logs/access_log combined env=!image
+RewriteRule "\.(png|gif|jpg)$" "-" [E=image:1]
+CustomLog logs/access_log combined env=!image
</highlight>
<p>Note that this same effect can be obtained using <directive
downloaded from your server.</p>
<highlight language="config">
-RewriteRule \.exe - [F]
+RewriteRule "\.exe" "-" [F]
</highlight>
<p>This example uses the "-" syntax for the rewrite target, which means
rewrite target when using the [G] flag:</p>
<highlight language="config">
-RewriteRule oldproduct - [G,NC]
+RewriteRule "oldproduct" "-" [G,NC]
</highlight>
<p>When using [G], an [L] is implied - that is, the response is returned
file extension to be parsed by the php handler:</p>
<highlight language="config">
-RewriteRule !\. - [H=application/x-httpd-php]
+RewriteRule "!\." "-" [H=application/x-httpd-php]
</highlight>
<p>
if they are requested with the <code>.phps</code> extension:</p>
<highlight language="config">
-RewriteRule ^(/source/.+\.php)s$ $1 [H=application/x-httpd-php-source]
+RewriteRule "^(/source/.+\.php)s$" "$1" [H=application/x-httpd-php-source]
</highlight>
<p>The regular expression above - <code>^(/source/.+\.php)s$</code> - will
module="mod_rewrite">RewriteRule</directive> will be skipped.</p>
<highlight language="config">
-RewriteBase /
-RewriteCond %{REQUEST_URI} !=/index.php
-RewriteRule ^(.*) /index.php?req=$1 [L,PT]
+RewriteBase "/"
+RewriteCond "%{REQUEST_URI}" !=/index.php
+RewriteRule "^(.*)" "/index.php?req=$1" [L,PT]
</highlight>
</section>
so until there are no more As to be replaced.
</p>
<highlight language="config">
-RewriteRule (.*)A(.*) $1B$2 [N]
+RewriteRule "(.*)A(.*)" "$1B$2" [N]
</highlight>
<p>You can think of this as a <code>while</code> loop: While this
pattern still matches (i.e., while the URI still contains an
iterations can be specified by adding to the N flag. </p>
<highlight language="config">
# Be willing to replace 1 character in each pass of the loop
-RewriteRule (.+)[><;]$ $1 [N=32000]
+RewriteRule "(.+)[><;]$" "$1" [N=32000]
# ... or, give up if after 10 loops
-RewriteRule (.+)[><;]$ $1 [N=10]
+RewriteRule "(.+)[><;]$" "$1" [N=10]
</highlight>
</section>
example.</p>
<highlight language="config">
-RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]
+RewriteRule "(.*\.(jpg|gif|png))$" "http://images.example.com$1" [P,NC]
</highlight>
</section>
</p>
<highlight language="config">
-RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]
+RewriteRule "^/anchor/(.+)" "/bigpage.html#$1" [NE,R]
</highlight>
<p>
image server, you might do something like the following:</p>
<highlight language="config">
-RewriteRule /(.*)\.(jpg|gif|png)$ http://images.example.com/$1.$2 [P]
+RewriteRule "/(.*)\.(jpg|gif|png)$" "http://images.example.com/$1.$2" [P]
</highlight>
<p>Use of the [P] flag implies [L] - that is, the request is immediately
<highlight language="config">
Alias "/icons" "/usr/local/apache/icons"
-RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT]
+RewriteRule "/pics/(.+)\.jpg$" "/icons/$1.gif" [PT]
</highlight>
<p>
<p>Consider the following rule:</p>
<highlight language="config">
-RewriteRule /pages/(.+) /page.php?page=$1 [QSA]
+RewriteRule "/pages/(.+)" "/page.php?page=$1" [QSA]
</highlight>
<p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be
<highlight language="config">
# Is the request for a non-existent file?
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
# If so, skip these two RewriteRules
-RewriteRule .? - [S=2]
+RewriteRule ".?" "-" [S=2]
-RewriteRule (.*\.gif) images.php?$1
-RewriteRule (.*\.html) docs.php?$1
+RewriteRule "(.*\.gif)" "images.php?$1"
+RewriteRule "(.*\.html)" "docs.php?$1"
</highlight>
<p>This technique is useful because a <directive
number of rules in the else-clause:</p>
<highlight language="config">
# Does the file exist?
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
-RewriteRule .? - [S=3]
+RewriteRule ".?" "-" [S=3]
# IF the file exists, then:
- RewriteRule (.*\.gif) images.php?$1
- RewriteRule (.*\.html) docs.php?$1
+ RewriteRule "(.*\.gif)" "images.php?$1"
+ RewriteRule "(.*\.html)" "docs.php?$1"
# Skip past the "else" stanza.
- RewriteRule .? - [S=1]
+ RewriteRule ".?" "-" [S=1]
# ELSE...
- RewriteRule (.*) 404.php?file=$1
+ RewriteRule "(.*)" "404.php?file=$1"
# END
</highlight>
<highlight language="config">
# Serve .pl files as plain text
-RewriteRule \.pl$ - [T=text/plain]
+RewriteRule "\.pl$" "-" [T=text/plain]
</highlight>
<p>Or, perhaps, if you have a camera that produces jpeg images without
<highlight language="config">
# Files with 'IMG' in the name are jpg images.
-RewriteRule IMG - [T=image/jpg]
+RewriteRule "IMG" "-" [T=image/jpg]
</highlight>
<p>Please note that this is a trivial example, and could be better done
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1585159:1673908 (outdated) -->
+<!-- English Revision: 1585159:1673932 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
<em>CondPattern</em>, back-references are internally created
which can be used with the strings <code>$N</code> and
<code>%N</code> (see below). These are available for creating
- the <em>Substitution</em> parameter of a
+ the <em>Substitution</em> parameter of a
<code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or
- the <em>TestString</em> parameter of a
+ the <em>TestString</em> parameter of a
<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code>.</p>
- <p> Captures in the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> patterns are (counterintuitively) available to
- all preceding
+ <p> Captures in the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> patterns are (counterintuitively) available to
+ all preceding
<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> directives,
because the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>
expression is evaluated before the individual conditions.</p>
- <p>Figure 1 shows to which
- locations the back-references are transferred for expansion as
- well as illustrating the flow of the RewriteRule, RewriteCond
- matching. In the next chapters, we will be exploring how to use
- these back-references, so do not fret if it seems a bit alien
+ <p>Figure 1 shows to which
+ locations the back-references are transferred for expansion as
+ well as illustrating the flow of the RewriteRule, RewriteCond
+ matching. In the next chapters, we will be exploring how to use
+ these back-references, so do not fret if it seems a bit alien
to you at first.
</p>
<li><var>[flags]</var>: options affecting the rewritten request.</li>
</ol>
-<p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
-It is initially (for the first rewrite rule or until a substitution occurs)
-matched against the URL-path of the incoming request (the part after the
-hostname but before any question mark indicating the beginning of a query
-string) or, in per-directory context, against the request's path relative
-to the directory for which the rule is defined. Once a substitution has
+<p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
+It is initially (for the first rewrite rule or until a substitution occurs)
+matched against the URL-path of the incoming request (the part after the
+hostname but before any question mark indicating the beginning of a query
+string) or, in per-directory context, against the request's path relative
+to the directory for which the rule is defined. Once a substitution has
occurred, the rules that follow are matched against the substituted
value.
</p>
<dl>
<dt>A full filesystem path to a resource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule ^/games /usr/local/games/web</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/games" "/usr/local/games/web"</pre>
<p>This maps a request to an arbitrary location on your filesystem, much
like the <code class="directive"><a href="../mod/mod_alias.html#alias">Alias</a></code> directive.</p>
<dt>A web-path to a resource</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule ^/foo$ /bar</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/foo$" "/bar"</pre>
<p>If <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> is set
to <code>/usr/local/apache2/htdocs</code>, then this directive would
<dt>An absolute URL</dt>
<dd>
-<pre class="prettyprint lang-config">RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/product/view$" "http://site2.example.com/seeproduct.html" [R]</pre>
<p>This tells the client to make a new request for the specified URL.</p>
</dd>
<p>The <var>Substitution</var> can also
contain <em>back-references</em> to parts of the incoming URL-path
matched by the <var>Pattern</var>. Consider the following:</p>
-<pre class="prettyprint lang-config">RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/product/(.*)/view$" "/var/web/productdb/$1"</pre>
<p>The variable <code>$1</code> will be replaced with whatever text
was matched by the expression inside the parenthesis in
matching behavior of a rule can be made case-insensitive by the
application of the <code>[NC]</code> flag:
</p>
-<pre class="prettyprint lang-config">RewriteRule ^puppy.html smalldog.html [NC]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^puppy.html" "smalldog.html" [NC]</pre>
<p>For more details on the available flags, their meanings, and
<p>For example, to send all requests from a particular IP range to a
different server, you could use:</p>
-<pre class="prettyprint lang-config">RewriteCond %{REMOTE_ADDR} ^10\.2\.
-RewriteRule (.*) http://intranet.example.com$1</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{REMOTE_ADDR}" "^10\.2\."
+RewriteRule "(.*)" "http://intranet.example.com$1"</pre>
<p>When more than
applied. For example, to deny requests that contain the word "hack" in
their query string, unless they also contain a cookie containing
the word "go", you could use:</p>
-<pre class="prettyprint lang-config">RewriteCond %{QUERY_STRING} hack
-RewriteCond %{HTTP_COOKIE} !go
-RewriteRule . - [F]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{QUERY_STRING}" "hack"
+RewriteCond "%{HTTP_COOKIE}" !go
+RewriteRule "." "-" [F]</pre>
<p>Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".</p>
variables <code>%1</code>, <code>%2</code>, etc. For example, this
will direct the request to a different directory depending on the
hostname used to access the site:</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} (.*)
-RewriteRule ^/(.*) /sites/%1/$1</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "(.*)"
+RewriteRule "^/(.*)" "/sites/%1/$1"</pre>
<p>If the request was for <code>http://example.com/foo/bar</code>,
then <code>%1</code> would contain <code>example.com</code>
<em>CondPattern</em>, back-references are internally created
which can be used with the strings <code>$N</code> and
<code>%N</code> (see below). These are available for creating
- the <em>Substitution</em> parameter of a
+ the <em>Substitution</em> parameter of a
<directive module="mod_rewrite">RewriteRule</directive> or
- the <em>TestString</em> parameter of a
+ the <em>TestString</em> parameter of a
<directive module="mod_rewrite">RewriteCond</directive>.</p>
<p> Captures in the <directive module="mod_rewrite"
- >RewriteRule</directive> patterns are (counterintuitively) available to
- all preceding
+ >RewriteRule</directive> patterns are (counterintuitively) available to
+ all preceding
<directive module="mod_rewrite">RewriteCond</directive> directives,
because the <directive module="mod_rewrite">RewriteRule</directive>
expression is evaluated before the individual conditions.</p>
- <p>Figure 1 shows to which
- locations the back-references are transferred for expansion as
- well as illustrating the flow of the RewriteRule, RewriteCond
- matching. In the next chapters, we will be exploring how to use
- these back-references, so do not fret if it seems a bit alien
+ <p>Figure 1 shows to which
+ locations the back-references are transferred for expansion as
+ well as illustrating the flow of the RewriteRule, RewriteCond
+ matching. In the next chapters, we will be exploring how to use
+ these back-references, so do not fret if it seems a bit alien
to you at first.
</p>
<li><var>[flags]</var>: options affecting the rewritten request.</li>
</ol>
-<p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
-It is initially (for the first rewrite rule or until a substitution occurs)
-matched against the URL-path of the incoming request (the part after the
-hostname but before any question mark indicating the beginning of a query
-string) or, in per-directory context, against the request's path relative
-to the directory for which the rule is defined. Once a substitution has
+<p>The <var>Pattern</var> is a <a href="#regex">regular expression</a>.
+It is initially (for the first rewrite rule or until a substitution occurs)
+matched against the URL-path of the incoming request (the part after the
+hostname but before any question mark indicating the beginning of a query
+string) or, in per-directory context, against the request's path relative
+to the directory for which the rule is defined. Once a substitution has
occurred, the rules that follow are matched against the substituted
value.
</p>
<dt>A full filesystem path to a resource</dt>
<dd>
<highlight language="config">
-RewriteRule ^/games /usr/local/games/web
+RewriteRule "^/games" "/usr/local/games/web"
</highlight>
<p>This maps a request to an arbitrary location on your filesystem, much
like the <directive module="mod_alias">Alias</directive> directive.</p>
<dt>A web-path to a resource</dt>
<dd>
<highlight language="config">
-RewriteRule ^/foo$ /bar
+RewriteRule "^/foo$" "/bar"
</highlight>
<p>If <directive module="core">DocumentRoot</directive> is set
to <code>/usr/local/apache2/htdocs</code>, then this directive would
<dt>An absolute URL</dt>
<dd>
<highlight language="config">
-RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]
+RewriteRule "^/product/view$" "http://site2.example.com/seeproduct.html" [R]
</highlight>
<p>This tells the client to make a new request for the specified URL.</p>
</dd>
contain <em>back-references</em> to parts of the incoming URL-path
matched by the <var>Pattern</var>. Consider the following:</p>
<highlight language="config">
-RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1
+RewriteRule "^/product/(.*)/view$" "/var/web/productdb/$1"
</highlight>
<p>The variable <code>$1</code> will be replaced with whatever text
was matched by the expression inside the parenthesis in
application of the <code>[NC]</code> flag:
</p>
<highlight language="config">
-RewriteRule ^puppy.html smalldog.html [NC]
+RewriteRule "^puppy.html" "smalldog.html" [NC]
</highlight>
<p>For more details on the available flags, their meanings, and
<p>For example, to send all requests from a particular IP range to a
different server, you could use:</p>
<highlight language="config">
-RewriteCond %{REMOTE_ADDR} ^10\.2\.
-RewriteRule (.*) http://intranet.example.com$1
+RewriteCond "%{REMOTE_ADDR}" "^10\.2\."
+RewriteRule "(.*)" "http://intranet.example.com$1"
</highlight>
<p>When more than
their query string, unless they also contain a cookie containing
the word "go", you could use:</p>
<highlight language="config">
-RewriteCond %{QUERY_STRING} hack
-RewriteCond %{HTTP_COOKIE} !go
-RewriteRule . - [F]
+RewriteCond "%{QUERY_STRING}" "hack"
+RewriteCond "%{HTTP_COOKIE}" !go
+RewriteRule "." "-" [F]
</highlight>
<p>Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".</p>
will direct the request to a different directory depending on the
hostname used to access the site:</p>
<highlight language="config">
-RewriteCond %{HTTP_HOST} (.*)
-RewriteRule ^/(.*) /sites/%1/$1
+RewriteCond "%{HTTP_HOST}" "(.*)"
+RewriteRule "^/(.*)" "/sites/%1/$1"
</highlight>
<p>If the request was for <code>http://example.com/foo/bar</code>,
then <code>%1</code> would contain <code>example.com</code>
</section>
</manualpage>
-
-
follows:</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteBase /products/
-RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P]
+RewriteBase "/products/"
+RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P]
ProxyPassReverse "/products/widget/" "http://product.example.com/widget/"</pre>
from one server to another, and you're not sure if all the content
has been migrated yet.</p>
-<pre class="prettyprint lang-config">RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^/(.*) http://old.example.com/$1 [P]
+<pre class="prettyprint lang-config">RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
+RewriteRule "^/(.*)" "http://old.example.com/$1" [P]
ProxyPassReverse "/" "http://old.example.com/"</pre>
</dd>
<highlight language="config">
RewriteEngine on
-RewriteBase /products/
-RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P]
+RewriteBase "/products/"
+RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P]
ProxyPassReverse "/products/widget/" "http://product.example.com/widget/"
</highlight>
has been migrated yet.</p>
<highlight language="config">
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^/(.*) http://old.example.com/$1 [P]
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
+RewriteRule "^/(.*)" "http://old.example.com/$1" [P]
ProxyPassReverse "/" "http://old.example.com/"
</highlight>
</dd>
following rule:</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT]</pre>
+RewriteRule "^<strong>/foo</strong>\.html$" "<strong>/bar</strong>.html" [PT]</pre>
</dd>
</dl>
change of the browsers and thus the users view:</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>]</pre>
+RewriteRule "^<strong>/foo</strong>\.html$" "<strong>bar</strong>.html" [<strong>R</strong>]</pre>
</dd>
<pre class="prettyprint lang-config">#With mod_rewrite
RewriteEngine on
-RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]</pre>
+RewriteRule "^/docs/(.+)" "http://new.example.com/docs/$1" [R,L]</pre>
<pre class="prettyprint lang-config">#With RedirectMatch
<code>/~quux/foo.cgi</code>.</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteBase /~quux/
-RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>]</pre>
+RewriteBase "/~quux/"
+RewriteRule "^foo\.html$" "foo.cgi" [H=<strong>cgi-script</strong>]</pre>
</dd>
</dl>
# when and only when document.php exists
<Directory "/var/www/htdocs">
RewriteEngine on
- RewriteBase /var/www/htdocs
+ RewriteBase "/var/www/htdocs"
- RewriteCond $1.php -f
- RewriteCond $1.html !-f
- RewriteRule ^(.*).html$ $1.php
+ RewriteCond "$1.php" -f
+ RewriteCond "$1.html" !-f
+ RewriteRule "^(.*).html$" "$1.php"
</Directory></pre>
</dd>
you might use one of the recipes below.</p>
<p>For sites running on a port other than 80:</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteCond %{SERVER_PORT} !^80$
-RewriteRule ^/?(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "!^www\.example\.com" [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteCond "%{SERVER_PORT}" "!^80$"
+RewriteRule "^/?(.*)" "http://www.example.com:%{SERVER_PORT}/$1" [L,R,NE]</pre>
<p>And for a site running on port 80</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "!^www\.example\.com" [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteRule "^/?(.*)" "http://www.example.com/$1" [L,R,NE]</pre>
<p>
<strong>example.com</strong>, you could use the following
recipe:</p>
-<pre class="prettyprint lang-config">RewriteCond %{HTTP_HOST} !^www\. [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]</pre>
+<pre class="prettyprint lang-config">RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteRule "^/?(.*)" "http://www.%{HTTP_HOST}/$1" [L,R,NE]</pre>
<p>These rulesets will work either in your main server configuration
# first try to find it in dir1/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f
-RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L]
+RewriteCond "%{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}" -f
+RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/<strong>dir1</strong>/$1" [L]
# second try to find it in dir2/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f
-RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L]
+RewriteCond "%{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}" -f
+RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/<strong>dir2</strong>/$1" [L]
# else go on for other Alias or ScriptAlias directives,
# etc.
-RewriteRule ^ - [PT]</pre>
+RewriteRule "^" "-" [PT]</pre>
</dd>
</dl>
<pre class="prettyprint lang-config">HostnameLookups on
RewriteEngine on
-RewriteMap multiplex txt:/path/to/map.mirrors
-RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]
-RewriteRule ^/(.*)$ ${multiplex:<strong>%1</strong>|http://www.example.com/}$1 [R,L]</pre>
+RewriteMap multiplex "txt:/path/to/map.mirrors"
+RewriteCond "%{REMOTE_HOST}" "([a-z]+)$" [NC]
+RewriteRule "^/(.*)$" "${multiplex:<strong>%1</strong>|http://www.example.com/}$1" [R,L]</pre>
<div class="example"><p><code>
we replace <code>/puppies</code> and <code>/canines</code>
by the canonical <code>/dogs</code>.</p>
-<pre class="prettyprint lang-config">RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/(puppies|canines)/(.*)" "/dogs/$2" [R]</pre>
</dd>
</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^/$ /about/ [<strong>R</strong>]</pre>
+RewriteRule "^/$" "/about/" [<strong>R</strong>]</pre>
<p>Note that this can also be handled using the <code class="directive"><a href="../mod/mod_alias.html#redirectmatch">RedirectMatch</a></code> directive:</p>
set to accomplish the same thing:</p>
<pre class="prettyprint lang-config"><Directory "/var/www/my_blog">
- RewriteBase /my_blog
+ RewriteBase "/my_blog"
- RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
- RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
- RewriteRule ^ index.php [PT]
+ RewriteCond "/var/www/my_blog/%{REQUEST_FILENAME}" !-f
+ RewriteCond "/var/www/my_blog/%{REQUEST_FILENAME}" !-d
+ RewriteRule "^" "index.php" [PT]
</Directory></pre>
<p>If, on the other hand, you wish to pass the requested URI as a query
string argument to index.php, you can replace that RewriteRule with:</p>
-<pre class="prettyprint lang-config">RewriteRule (.*) index.php?$1 [PT,QSA]</pre>
+<pre class="prettyprint lang-config">RewriteRule "(.*)" "index.php?$1" [PT,QSA]</pre>
<p>Note that these rulesets can be used in a <code>.htaccess</code>
<p> Many of the solutions in this section will all use the same condition,
which leaves the matched value in the %2 backreference. %1 is the beginining
of the query string (up to the key of intererest), and %3 is the remainder. This
-condition is a bit complex for flexibility and to avoid double '&&' in the
+condition is a bit complex for flexibility and to avoid double '&&' in the
substitutions.</p>
<ul>
<li>This solution removes the matching key and value:
<pre class="prettyprint lang-config"># Remove mykey=???
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteRule (.*) $1?%1%3</pre>
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteRule "(.*)" "$1?%1%3"</pre>
</li>
discarding the rest of the original query by appending a '?':
<pre class="prettyprint lang-config"># Copy from query string to PATH_INFO
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteRule (.*) $1/products/%2/? [PT]</pre>
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteRule "(.*)" "$1/products/%2/?" [PT]</pre>
</li>
<li>This solution checks the captured value in a subsequent condition:
<pre class="prettyprint lang-config"># Capture the value of mykey in the query string
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteCond %2 !=not-so-secret-value
-RewriteRule (.*) - [F]</pre>
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteCond "%2" !=not-so-secret-value
+RewriteRule "(.*)" "-" [F]</pre>
</li>
<li>This solution shows the reverse of the previous ones, copying
path components (perhaps PATH_INFO) from the URL into the query string.
-<pre class="prettyprint lang-config"># The desired URL might be /products/kitchen-sink, and the script expects
+<pre class="prettyprint lang-config"># The desired URL might be /products/kitchen-sink, and the script expects
# /path?products=kitchen-sink.
-RewriteRule ^/?path/([^/]+)/([^/]+) /path?$1=$2 [PT]</pre>
+RewriteRule "^/?path/([^/]+)/([^/]+)" "/path?$1=$2" [PT]</pre>
</li>
</ul>
<highlight language="config">
RewriteEngine on
-RewriteRule ^<strong>/foo</strong>\.html$ <strong>/bar</strong>.html [PT]
+RewriteRule "^<strong>/foo</strong>\.html$" "<strong>/bar</strong>.html" [PT]
</highlight>
</dd>
</dl>
<highlight language="config">
RewriteEngine on
-RewriteRule ^<strong>/foo</strong>\.html$ <strong>bar</strong>.html [<strong>R</strong>]
+RewriteRule "^<strong>/foo</strong>\.html$" "<strong>bar</strong>.html" [<strong>R</strong>]
</highlight>
</dd>
<highlight language="config">
#With mod_rewrite
RewriteEngine on
-RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]
+RewriteRule "^/docs/(.+)" "http://new.example.com/docs/$1" [R,L]
</highlight>
<highlight language="config">
<highlight language="config">
RewriteEngine on
-RewriteBase /~quux/
-RewriteRule ^foo\.html$ foo.cgi [H=<strong>cgi-script</strong>]
+RewriteBase "/~quux/"
+RewriteRule "^foo\.html$" "foo.cgi" [H=<strong>cgi-script</strong>]
</highlight>
</dd>
</dl>
# when and only when document.php exists
<Directory "/var/www/htdocs">
RewriteEngine on
- RewriteBase /var/www/htdocs
+ RewriteBase "/var/www/htdocs"
- RewriteCond $1.php -f
- RewriteCond $1.html !-f
- RewriteRule ^(.*).html$ $1.php
+ RewriteCond "$1.php" -f
+ RewriteCond "$1.html" !-f
+ RewriteRule "^(.*).html$" "$1.php"
</Directory>
</highlight>
</dd>
<p>For sites running on a port other than 80:</p>
<highlight language="config">
-RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteCond %{SERVER_PORT} !^80$
-RewriteRule ^/?(.*) http://www.example.com:%{SERVER_PORT}/$1 [L,R,NE]
+RewriteCond "%{HTTP_HOST}" "!^www\.example\.com" [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteCond "%{SERVER_PORT}" "!^80$"
+RewriteRule "^/?(.*)" "http://www.example.com:%{SERVER_PORT}/$1" [L,R,NE]
</highlight>
<p>And for a site running on port 80</p>
<highlight language="config">
-RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]
+RewriteCond "%{HTTP_HOST}" "!^www\.example\.com" [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteRule "^/?(.*)" "http://www.example.com/$1" [L,R,NE]
</highlight>
<p>
recipe:</p>
<highlight language="config">
-RewriteCond %{HTTP_HOST} !^www\. [NC]
-RewriteCond %{HTTP_HOST} !^$
-RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]
+RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
+RewriteCond "%{HTTP_HOST}" "!^$"
+RewriteRule "^/?(.*)" "http://www.%{HTTP_HOST}/$1" [L,R,NE]
</highlight>
<p>These rulesets will work either in your main server configuration
# first try to find it in dir1/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI} -f
-RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir1</strong>/$1 [L]
+RewriteCond "%{DOCUMENT_ROOT}/<strong>dir1</strong>/%{REQUEST_URI}" -f
+RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/<strong>dir1</strong>/$1" [L]
# second try to find it in dir2/...
# ...and if found stop and be happy:
-RewriteCond %{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI} -f
-RewriteRule ^(.+) %{DOCUMENT_ROOT}/<strong>dir2</strong>/$1 [L]
+RewriteCond "%{DOCUMENT_ROOT}/<strong>dir2</strong>/%{REQUEST_URI}" -f
+RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/<strong>dir2</strong>/$1" [L]
# else go on for other Alias or ScriptAlias directives,
# etc.
-RewriteRule ^ - [PT]
+RewriteRule "^" "-" [PT]
</highlight>
</dd>
</dl>
<highlight language="config">
HostnameLookups on
RewriteEngine on
-RewriteMap multiplex txt:/path/to/map.mirrors
-RewriteCond %{REMOTE_HOST} ([a-z]+)$ [NC]
-RewriteRule ^/(.*)$ ${multiplex:<strong>%1</strong>|http://www.example.com/}$1 [R,L]
+RewriteMap multiplex "txt:/path/to/map.mirrors"
+RewriteCond "%{REMOTE_HOST}" "([a-z]+)$" [NC]
+RewriteRule "^/(.*)$" "${multiplex:<strong>%1</strong>|http://www.example.com/}$1" [R,L]
</highlight>
<example>
by the canonical <code>/dogs</code>.</p>
<highlight language="config">
-RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]
+RewriteRule "^/(puppies|canines)/(.*)" "/dogs/$2" [R]
</highlight>
</dd>
<highlight language="config">
RewriteEngine on
-RewriteRule ^/$ /about/ [<strong>R</strong>]
+RewriteRule "^/$" "/about/" [<strong>R</strong>]
</highlight>
<p>Note that this can also be handled using the <directive
<highlight language="config">
<Directory "/var/www/my_blog">
- RewriteBase /my_blog
+ RewriteBase "/my_blog"
- RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-f
- RewriteCond /var/www/my_blog/%{REQUEST_FILENAME} !-d
- RewriteRule ^ index.php [PT]
+ RewriteCond "/var/www/my_blog/%{REQUEST_FILENAME}" !-f
+ RewriteCond "/var/www/my_blog/%{REQUEST_FILENAME}" !-d
+ RewriteRule "^" "index.php" [PT]
</Directory>
</highlight>
string argument to index.php, you can replace that RewriteRule with:</p>
<highlight language="config">
-RewriteRule (.*) index.php?$1 [PT,QSA]
+RewriteRule "(.*)" "index.php?$1" [PT,QSA]
</highlight>
<p>Note that these rulesets can be used in a <code>.htaccess</code>
<highlight language="config">
# Remove mykey=???
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteRule (.*) $1?%1%3
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteRule "(.*)" "$1?%1%3"
</highlight>
</li>
<highlight language="config">
# Copy from query string to PATH_INFO
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteRule (.*) $1/products/%2/? [PT]
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteRule "(.*)" "$1/products/%2/?" [PT]
</highlight>
</li>
<highlight language="config">
# Capture the value of mykey in the query string
-RewriteCond %{QUERY_STRING} (.*(?:^|&))mykey=([^&]*)&?(.*)&?$
-RewriteCond %2 !=not-so-secret-value
-RewriteRule (.*) - [F]
+RewriteCond "%{QUERY_STRING}" "(.*(?:^|&))mykey=([^&]*)&?(.*)&?$"
+RewriteCond "%2" !=not-so-secret-value
+RewriteRule "(.*)" "-" [F]
</highlight>
</li>
<highlight language="config">
# The desired URL might be /products/kitchen-sink, and the script expects
# /path?products=kitchen-sink.
-RewriteRule ^/?path/([^/]+)/([^/]+) /path?$1=$2 [PT]
+RewriteRule "^/?path/([^/]+)/([^/]+)" "/path?$1=$2" [PT]
</highlight>
</li>
</ul>
<p>The syntax of the <code>RewriteMap</code> directive is as
follows:</p>
-<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></pre>
+<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
+</pre>
<p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an
<p>For example, you can define a
<code class="directive">RewriteMap</code> as:</p>
- <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
+ <pre class="prettyprint lang-config">RewriteMap examplemap "txt:/path/to/file/map.txt"</pre>
<p>You would then be able to use this map in a
<code class="directive">RewriteRule</code> as follows:</p>
-<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
+ <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>
<p>A default value can be specified in the event that nothing is found
in the map:</p>
-<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1|/not_found.html}"</pre>
<div class="note"><h3>Per-directory and .htaccess context</h3>
</p>
<p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
- <pre class="prettyprint lang-config">RewriteMap lc int:tolower
-RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]</pre>
+ <pre class="prettyprint lang-config">RewriteMap lc "int:tolower"
+RewriteRule "(.*?[A-Z]+.*)" "${lc:$1}" [R]</pre>
<div class="note">
product IDs for easier-to-remember URLs, using the following
recipe:</p>
<p><strong>Product to ID configuration</strong></p>
- <pre class="prettyprint lang-config">RewriteMap product2id txt:/etc/apache2/productmap.txt
-RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
+ <pre class="prettyprint lang-config">RewriteMap product2id "txt:/etc/apache2/productmap.txt"
+RewriteRule "^/product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]</pre>
<p>We assume here that the <code>prods.php</code> script knows what
scope. If you're planning to use this in a <code>.htaccess</code>
file, you'll need to remove the leading slash from the rewrite
pattern in order for it to match anything:
- <pre class="prettyprint lang-config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
+ <pre class="prettyprint lang-config">RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]</pre>
</div>
dynamic www5|www6
</code></p></div>
<p><strong>Configuration directives</strong></p>
- <pre class="prettyprint lang-config">RewriteMap servers rnd:/path/to/file/map.txt
+ <pre class="prettyprint lang-config">RewriteMap servers "rnd:/path/to/file/map.txt"
-RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L]
-RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]</pre>
+RewriteRule "^/(.*\.(png|gif|jpg))" "http://${servers:static}/$1" [NC,P,L]
+RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L]</pre>
<p>So, when an image is requested and the first of these rules is
<p>You may optionally specify a particular dbm type:</p>
- <pre class="prettyprint lang-config">RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm</pre>
+ <pre class="prettyprint lang-config">RewriteMap examplemap "dbm=sdbm:/etc/apache/mapfile.dbm"</pre>
<p>The type can be sdbm, gdbm, ndbm or db.
<p>You can then reference the resulting file in your
<code>RewriteMap</code> directive:</p>
-<pre class="prettyprint lang-config">RewriteMap mapname dbm:/etc/apache/mapfile.map</pre>
+<pre class="prettyprint lang-config">RewriteMap mapname "dbm:/etc/apache/mapfile.map"</pre>
<div class="note">
<p>A simple example is shown here which will replace all dashes with
underscores in a request URI.</p>
-
+
<p><strong>Rewrite configuration</strong></p>
- <pre class="prettyprint lang-config">RewriteMap d2u prg:/www/bin/dash2under.pl apache:apache<br />
-RewriteRule - ${d2u:%{REQUEST_URI}}</pre>
+ <pre class="prettyprint lang-config">RewriteMap d2u "prg:/www/bin/dash2under.programlisting" apache:apache<br />
+RewriteRule "-" "${d2u:%{REQUEST_URI}}"</pre>
<p><strong>dash2under.pl</strong></p>
<p>For example, you can define a
<directive>RewriteMap</directive> as:</p>
<highlight language="config">
-RewriteMap examplemap txt:/path/to/file/map.txt
+RewriteMap examplemap "txt:/path/to/file/map.txt"
</highlight>
<p>You would then be able to use this map in a
<directive>RewriteRule</directive> as follows:</p>
<highlight language="config">
-RewriteRule ^/ex/(.*) ${examplemap:$1}
+RewriteRule "^/ex/(.*)" "${examplemap:$1}"
</highlight>
<p>A default value can be specified in the event that nothing is found
in the map:</p>
<highlight language="config">
-RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}
+RewriteRule "^/ex/(.*)" "${examplemap:$1|/not_found.html}"
</highlight>
<note><title>Per-directory and .htaccess context</title>
<p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
<highlight language="config">
-RewriteMap lc int:tolower
-RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]
+RewriteMap lc "int:tolower"
+RewriteRule "(.*?[A-Z]+.*)" "${lc:$1}" [R]
</highlight>
<note>
recipe:</p>
<p><strong>Product to ID configuration</strong></p>
<highlight language="config">
-RewriteMap product2id txt:/etc/apache2/productmap.txt
-RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]
+RewriteMap product2id "txt:/etc/apache2/productmap.txt"
+RewriteRule "^/product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]
</highlight>
<p>We assume here that the <code>prods.php</code> script knows what
file, you'll need to remove the leading slash from the rewrite
pattern in order for it to match anything:
<highlight language="config">
-RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]
+RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]
</highlight>
</note>
</example>
<p><strong>Configuration directives</strong></p>
<highlight language="config">
-RewriteMap servers rnd:/path/to/file/map.txt
+RewriteMap servers "rnd:/path/to/file/map.txt"
-RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L]
-RewriteRule ^/(.*) http://${servers:dynamic}/$1 [P,L]
+RewriteRule "^/(.*\.(png|gif|jpg))" "http://${servers:static}/$1" [NC,P,L]
+RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L]
</highlight>
<p>So, when an image is requested and the first of these rules is
<p>You may optionally specify a particular dbm type:</p>
<highlight language="config">
-RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm
+RewriteMap examplemap "dbm=sdbm:/etc/apache/mapfile.dbm"
</highlight>
<p>The type can be sdbm, gdbm, ndbm or db.
<code>RewriteMap</code> directive:</p>
<highlight language="config">
-RewriteMap mapname dbm:/etc/apache/mapfile.map
+RewriteMap mapname "dbm:/etc/apache/mapfile.map"
</highlight>
<note>
<p><strong>Rewrite configuration</strong></p>
<highlight language="config">
-RewriteMap d2u prg:/www/bin/dash2under.pl apache:apache<br />
-RewriteRule - ${d2u:%{REQUEST_URI}}
+RewriteMap d2u "prg:/www/bin/dash2under.programlisting" apache:apache<br />
+RewriteRule "-" "${d2u:%{REQUEST_URI}}"
</highlight>
<p><strong>dash2under.pl</strong></p>
for /foo/bar/baz is being processed, an expression like ^bar/baz$ would
match.</p>
- <p> If a substitution is made in per-directory context, a new internal
- subrequest is issued with the new URL, which restarts processing of the
- request phases. If the substitution is a relative path, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritebase">RewriteBase</a></code> directive
+ <p> If a substitution is made in per-directory context, a new internal
+ subrequest is issued with the new URL, which restarts processing of the
+ request phases. If the substitution is a relative path, the <code class="directive"><a href="../mod/mod_rewrite.html#rewritebase">RewriteBase</a></code> directive
determines the URL-path prefix prepended to the substitution.
- In per-directory context, care must be taken to
+ In per-directory context, care must be taken to
create rules which will eventually (in some future "round" of per-directory
rewrite processing) not perform a substitution to avoid looping.
(See <a href="http://wiki.apache.org/httpd/RewriteLooping">RewriteLooping</a>
<tr>
<td>VirtualHost section</td>
- <td>RewriteRule ^/images/(.+)\.jpg /images/$1.gif</td>
+ <td>RewriteRule "^/images/(.+)\.jpg" "/images/$1.gif"</td>
</tr>
<tr>
<td>.htaccess file in document root</td>
- <td>RewriteRule ^images/(.+)\.jpg images/$1.gif</td>
+ <td>RewriteRule "^images/(.+)\.jpg" "images/$1.gif"</td>
</tr>
<tr>
<td>.htaccess file in images directory</td>
- <td>RewriteRule ^(.+)\.jpg $1.gif</td>
+ <td>RewriteRule "^(.+)\.jpg" "$1.gif"</td>
</tr>
</table>
<p>For even more insight into how mod_rewrite manipulates URLs in
- different contexts, you should consult the <a href="../mod/mod_rewrite.html#logging">log entries</a> made during
+ different contexts, you should consult the <a href="../mod/mod_rewrite.html#logging">log entries</a> made during
rewriting.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<p>In per-directory context (i.e., within <code>.htaccess</code> files
and <code>Directory</code> blocks), these rules are being applied
after a URL has already been translated to a filename. Because of
- this, the URL-path that mod_rewrite initially compares <directive
+ this, the URL-path that mod_rewrite initially compares <directive
module="mod_rewrite">RewriteRule</directive> directives against
is the full filesystem path to the translated filename with the current
directories path (including a trailing slash) removed from the front.</p>
for /foo/bar/baz is being processed, an expression like ^bar/baz$ would
match.</p>
- <p> If a substitution is made in per-directory context, a new internal
- subrequest is issued with the new URL, which restarts processing of the
- request phases. If the substitution is a relative path, the <directive
- module="mod_rewrite">RewriteBase</directive> directive
+ <p> If a substitution is made in per-directory context, a new internal
+ subrequest is issued with the new URL, which restarts processing of the
+ request phases. If the substitution is a relative path, the <directive
+ module="mod_rewrite">RewriteBase</directive> directive
determines the URL-path prefix prepended to the substitution.
- In per-directory context, care must be taken to
+ In per-directory context, care must be taken to
create rules which will eventually (in some future "round" of per-directory
rewrite processing) not perform a substitution to avoid looping.
(See <a href="http://wiki.apache.org/httpd/RewriteLooping">RewriteLooping</a>
<tr>
<td>VirtualHost section</td>
- <td>RewriteRule ^/images/(.+)\.jpg /images/$1.gif</td>
+ <td>RewriteRule "^/images/(.+)\.jpg" "/images/$1.gif"</td>
</tr>
<tr>
<td>.htaccess file in document root</td>
- <td>RewriteRule ^images/(.+)\.jpg images/$1.gif</td>
+ <td>RewriteRule "^images/(.+)\.jpg" "images/$1.gif"</td>
</tr>
<tr>
<td>.htaccess file in images directory</td>
- <td>RewriteRule ^(.+)\.jpg $1.gif</td>
+ <td>RewriteRule "^(.+)\.jpg" "$1.gif"</td>
</tr>
</table>
<p>For even more insight into how mod_rewrite manipulates URLs in
different contexts, you should consult the <a
- href="../mod/mod_rewrite.html#logging">log entries</a> made during
+ href="../mod/mod_rewrite.html#logging">log entries</a> made during
rewriting.</p>
</section>
</manualpage>
-
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
-RewriteCond ${lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$
-RewriteRule ^(.*) /home/<strong>%1</strong>/www$1</pre>
+RewriteCond "${lowercase:%{<strong>HTTP_HOST</strong>}}" "^www\.<strong>([^.]+)</strong>\.example\.com$"
+RewriteRule "^(.*)" "/home/<strong>%1</strong>/www$1"</pre>
</dd>
<dt>Discussion</dt>
RewriteEngine On
# a ServerName derived from a Host: header may be any case at all
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
## deal with normal documents first:
# allow Alias /icons/ to work - repeat for other aliases
-RewriteCond %{REQUEST_URI} !^/icons/
+RewriteCond "%{REQUEST_URI}" "!^/icons/"
# allow CGIs to work
-RewriteCond %{REQUEST_URI} !^/cgi-bin/
+RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
# do the magic
-RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1
+RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1"
## and now deal with CGIs - we have to force a handler
-RewriteCond %{REQUEST_URI} ^/cgi-bin/
-RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script]</pre>
+RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
+RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1" [H=cgi-script]</pre>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
# define the map file
-RewriteMap vhost txt:/www/conf/vhost.map
+RewriteMap vhost "txt:/www/conf/vhost.map"
# deal with aliases as above
-RewriteCond %{REQUEST_URI} !^/icons/
-RewriteCond %{REQUEST_URI} !^/cgi-bin/
-RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
+RewriteCond "%{REQUEST_URI}" "!^/icons/"
+RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
+RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
# this does the file-based remap
-RewriteCond ${vhost:%1} ^(/.*)$
-RewriteRule ^/(.*)$ %1/docs/$1
+RewriteCond "${vhost:%1}" "^(/.*)$"
+RewriteRule "^/(.*)$" "%1/docs/$1"
-RewriteCond %{REQUEST_URI} ^/cgi-bin/
-RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
-RewriteCond ${vhost:%1} ^(/.*)$
-RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script]</pre>
+RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
+RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
+RewriteCond "${vhost:%1}" "^(/.*)$"
+RewriteRule "^/(.*)$" "%1/cgi-bin/$1" [H=cgi-script]</pre>
</div></div>
<highlight language="config">
RewriteEngine on
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
-RewriteCond ${lowercase:%{<strong>HTTP_HOST</strong>}} ^www\.<strong>([^.]+)</strong>\.example\.com$
-RewriteRule ^(.*) /home/<strong>%1</strong>/www$1
+RewriteCond "${lowercase:%{<strong>HTTP_HOST</strong>}}" "^www\.<strong>([^.]+)</strong>\.example\.com$"
+RewriteRule "^(.*)" "/home/<strong>%1</strong>/www$1"
</highlight></dd>
<dt>Discussion</dt>
RewriteEngine On
# a ServerName derived from a Host: header may be any case at all
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
## deal with normal documents first:
# allow Alias /icons/ to work - repeat for other aliases
-RewriteCond %{REQUEST_URI} !^/icons/
+RewriteCond "%{REQUEST_URI}" "!^/icons/"
# allow CGIs to work
-RewriteCond %{REQUEST_URI} !^/cgi-bin/
+RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
# do the magic
-RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1
+RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1"
## and now deal with CGIs - we have to force a handler
-RewriteCond %{REQUEST_URI} ^/cgi-bin/
-RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-script]
+RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
+RewriteRule "^/(.*)$" "/www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1" [H=cgi-script]
</highlight>
</section>
<highlight language="config">
RewriteEngine on
-RewriteMap lowercase int:tolower
+RewriteMap lowercase "int:tolower"
# define the map file
-RewriteMap vhost txt:/www/conf/vhost.map
+RewriteMap vhost "txt:/www/conf/vhost.map"
# deal with aliases as above
-RewriteCond %{REQUEST_URI} !^/icons/
-RewriteCond %{REQUEST_URI} !^/cgi-bin/
-RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
+RewriteCond "%{REQUEST_URI}" "!^/icons/"
+RewriteCond "%{REQUEST_URI}" "!^/cgi-bin/"
+RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
# this does the file-based remap
-RewriteCond ${vhost:%1} ^(/.*)$
-RewriteRule ^/(.*)$ %1/docs/$1
+RewriteCond "${vhost:%1}" "^(/.*)$"
+RewriteRule "^/(.*)$" "%1/docs/$1"
-RewriteCond %{REQUEST_URI} ^/cgi-bin/
-RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
-RewriteCond ${vhost:%1} ^(/.*)$
-RewriteRule ^/(.*)$ %1/cgi-bin/$1 [H=cgi-script]
+RewriteCond "%{REQUEST_URI}" "^/cgi-bin/"
+RewriteCond "${lowercase:%{SERVER_NAME}}" "^(.+)$"
+RewriteCond "${vhost:%1}" "^(/.*)$"
+RewriteRule "^/(.*)$" "%1/cgi-bin/$1" [H=cgi-script]
</highlight>
</section>
order.</p>
<p>Later sections override earlier ones, however each module is responsible
- for interpreting what form this override takes. A later configuration section
+ for interpreting what form this override takes. A later configuration section
with directives from a given module might cause a conceptual "merge" of some
- directives, all directives, or a complete replacement of the modules
- configuration with the module defaults and directives explicitly listed in
+ directives, all directives, or a complete replacement of the modules
+ configuration with the module defaults and directives explicitly listed in
the later context.</p>
<div class="note"><h3>Technical Note</h3>
order.</p>
<p>Later sections override earlier ones, however each module is responsible
- for interpreting what form this override takes. A later configuration section
+ for interpreting what form this override takes. A later configuration section
with directives from a given module might cause a conceptual "merge" of some
- directives, all directives, or a complete replacement of the modules
- configuration with the module defaults and directives explicitly listed in
+ directives, all directives, or a complete replacement of the modules
+ configuration with the module defaults and directives explicitly listed in
the later context.</p>
<note><title>Technical Note</title>
<?xml-stylesheet type="text/xsl" href="./style/manual.fr.xsl"?>
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
-<!-- English Revision: 1636195:1673908 (outdated) -->
+<!-- English Revision: 1636195:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?>
-<!-- English Revision: 420990:1673908 (outdated) -->
+<!-- English Revision: 420990:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ko.xsl"?>
-<!-- English Revision: 105989:1673908 (outdated) -->
+<!-- English Revision: 105989:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.tr.xsl"?>
-<!-- English Revision: 1300910:1673908 (outdated) -->
+<!-- English Revision: 1300910:1673930 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
scheme). Using <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> however, you can
manipulate relative hyperlinks, to achieve the same effect.</p>
<pre class="prettyprint lang-config">RewriteEngine on
-RewriteRule ^/(.*)_SSL$ https://%{SERVER_NAME}/$1 [R,L]
-RewriteRule ^/(.*)_NOSSL$ http://%{SERVER_NAME}/$1 [R,L]</pre>
+RewriteRule "^/(.*)_SSL$" "https://%{SERVER_NAME}/$1" [R,L]
+RewriteRule "^/(.*)_NOSSL$" "http://%{SERVER_NAME}/$1" [R,L]</pre>
<p>This rewrite ruleset lets you use hyperlinks of the form
handshake is finished, but the information is needed in order to
complete the SSL handshake phase. See the next question for how to
circumvent this issue.</p>
-
+
<p>Note that if you have a wildcard SSL certificate, or a
certificate that has multiple hostnames on it using subjectAltName
fields, you can use SSL on name-based virtual hosts without further
manipulate relative hyperlinks, to achieve the same effect.</p>
<highlight language="config">
RewriteEngine on
-RewriteRule ^/(.*)_SSL$ https://%{SERVER_NAME}/$1 [R,L]
-RewriteRule ^/(.*)_NOSSL$ http://%{SERVER_NAME}/$1 [R,L]
+RewriteRule "^/(.*)_SSL$" "https://%{SERVER_NAME}/$1" [R,L]
+RewriteRule "^/(.*)_NOSSL$" "http://%{SERVER_NAME}/$1" [R,L]
</highlight>
<p>This rewrite ruleset lets you use hyperlinks of the form
handshake is finished, but the information is needed in order to
complete the SSL handshake phase. See the next question for how to
circumvent this issue.</p>
-
+
<p>Note that if you have a wildcard SSL certificate, or a
certificate that has multiple hostnames on it using subjectAltName
fields, you can use SSL on name-based virtual hosts without further
# Force clients from the Internet to use HTTPS
RewriteEngine on
RewriteCond "%{REMOTE_ADDR}" "!^192\.168\.1\.[0-9]+$"
- RewriteCond "%{HTTPS}" "!=on"
- RewriteRule "." "-" [F]
+ RewriteCond "%{HTTPS}" "!=on"
+ RewriteRule "." "-" [F]
# Allow Network Access and/or Basic Auth
Satisfy any
# Force clients from the Internet to use HTTPS
RewriteEngine on
RewriteCond "%{REMOTE_ADDR}" "!^192\.168\.1\.[0-9]+$"
- RewriteCond "%{HTTPS}" "!=on"
- RewriteRule "." "-" [F]
+ RewriteCond "%{HTTPS}" "!=on"
+ RewriteRule "." "-" [F]
# Allow Network Access and/or Basic Auth
Satisfy any
option as indicated above, or to syslog if <code>--with-suexec-syslog</code>
is used. If you feel you have configured and
installed the wrapper properly, have a look at the log and the
- error_log for the server to see where you may have gone astray.
+ error_log for the server to see where you may have gone astray.
The output of <code>"suexec -V"</code> will show the options
used to compile suexec, if using a binary distribution.</p>
option as indicated above, or to syslog if <code>--with-suexec-syslog</code>
is used. If you feel you have configured and
installed the wrapper properly, have a look at the log and the
- error_log for the server to see where you may have gone astray.
+ error_log for the server to see where you may have gone astray.
The output of <code>"suexec -V"</code> will show the options
used to compile suexec, if using a binary distribution.</p>
<p>If a directory is requested (i.e. a path ending with
<code>/</code>), the file served from that directory is defined by
the <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code> directive.
- For example, if <code>DocumentRoot</code> were set as above, and
+ For example, if <code>DocumentRoot</code> were set as above, and
you were to set:</p>
<div class="example"><p><code>DirectoryIndex index.html index.php</code></p></div>
<pre class="prettyprint lang-config">Substitute s/internal\.example\.com/www.example.com/i</pre>
-<p>For more sophisticated rewriting of links in HTML and XHTML, the
+<p>For more sophisticated rewriting of links in HTML and XHTML, the
<code class="module"><a href="./mod/mod_proxy_html.html">mod_proxy_html</a></code> module is also available. It allows you
to create maps of URLs that need to be rewritten, so that complex
proxying scenarios can be handled.</p>
<p>If a directory is requested (i.e. a path ending with
<code>/</code>), the file served from that directory is defined by
the <directive module="mod_dir">DirectoryIndex</directive> directive.
- For example, if <code>DocumentRoot</code> were set as above, and
+ For example, if <code>DocumentRoot</code> were set as above, and
you were to set:</p>
<example>DirectoryIndex index.html index.php</example>
Substitute s/internal\.example\.com/www.example.com/i
</highlight>
-<p>For more sophisticated rewriting of links in HTML and XHTML, the
+<p>For more sophisticated rewriting of links in HTML and XHTML, the
<module>mod_proxy_html</module> module is also available. It allows you
to create maps of URLs that need to be rewritten, so that complex
proxying scenarios can be handled.</p>
<?xml-stylesheet type="text/xsl" href="./style/manual.fr.xsl"?>
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : Vincent Deffontaines -->
-<!-- English Revision: 1561569:1673908 (outdated) -->
+<!-- English Revision: 1561569:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?>
-<!-- English Revision: 151408:1673908 (outdated) -->
+<!-- English Revision: 151408:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="EUC-KR" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.ko.xsl"?>
-<!-- English Revision: 151408:1673908 (outdated) -->
+<!-- English Revision: 151408:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.tr.xsl"?>
-<!-- English Revision: 1310494:1673908 (outdated) -->
+<!-- English Revision: 1310494:1673930 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
sites on a single IP address.</a></h2>
<p>Your server has multiple hostnames that resolve to a single address,
- and you want to respond differently for <code>www.example.com</code>
+ and you want to respond differently for <code>www.example.com</code>
and <code>www.example.org</code>.</p>
<div class="note"><h3>Note</h3><p>Creating virtual
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
-
+
# Other directives here
</VirtualHost>
<h3>Note</h3>
<p>You may replace <code>*</code> with a specific IP address
- on the system. Such virtual hosts will only be used for
- HTTP requests received on connection to the specified IP
+ on the system. Such virtual hosts will only be used for
+ HTTP requests received on connection to the specified IP
address.</p>
<p>However, it is additionally useful to use <code>*</code>
<VirtualHost 172.20.30.50>
DocumentRoot "/www/example1"
ServerName www.example.com
-
+
# Other directives here ...
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot "/www/example2"
ServerName www.example.org
-
+
# Other directives here ...
</VirtualHost></pre>
# primary vhost
DocumentRoot "/www/subdomain"
RewriteEngine On
- RewriteRule . /www/subdomain/index.html
+ RewriteRule "." "/www/subdomain/index.html"
# ...
</VirtualHost>
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
- RewriteRule ^(/sub1/.*) /www/subdomain$1
+ RewriteRule "^(/sub1/.*)" "/www/subdomain$1"
# ...
</VirtualHost>
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
- RewriteRule ^(/sub2/.*) /www/subdomain$1
+ RewriteRule "^(/sub2/.*)" "/www/subdomain$1"
# ...
</VirtualHost></pre>
sites on a single IP address.</title>
<p>Your server has multiple hostnames that resolve to a single address,
- and you want to respond differently for <code>www.example.com</code>
+ and you want to respond differently for <code>www.example.com</code>
and <code>www.example.org</code>.</p>
<note><title>Note</title><p>Creating virtual
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
-
+
# Other directives here
</VirtualHost>
<title>Note</title>
<p>You may replace <code>*</code> with a specific IP address
- on the system. Such virtual hosts will only be used for
- HTTP requests received on connection to the specified IP
+ on the system. Such virtual hosts will only be used for
+ HTTP requests received on connection to the specified IP
address.</p>
<p>However, it is additionally useful to use <code>*</code>
<VirtualHost 172.20.30.50>
DocumentRoot "/www/example1"
ServerName www.example.com
-
+
# Other directives here ...
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot "/www/example2"
ServerName www.example.org
-
+
# Other directives here ...
</VirtualHost>
</highlight>
# primary vhost
DocumentRoot "/www/subdomain"
RewriteEngine On
- RewriteRule . /www/subdomain/index.html
+ RewriteRule "." "/www/subdomain/index.html"
# ...
</VirtualHost>
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
- RewriteRule ^(/sub1/.*) /www/subdomain$1
+ RewriteRule "^(/sub1/.*)" "/www/subdomain$1"
# ...
</VirtualHost>
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
- RewriteRule ^(/sub2/.*) /www/subdomain$1
+ RewriteRule "^(/sub2/.*)" "/www/subdomain$1"
# ...
</VirtualHost>
</highlight>
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
-<!-- English Revision: 1628690:1673917 (outdated) -->
+<!-- English Revision: 1628690:1673930 (outdated) -->
<!-- French translation by Vincent Deffontaines, Alain B. -->
<!-- reviewed by Lucien Gentis -->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
-<!-- English Revision: 659902:1673917 (outdated) -->
+<!-- English Revision: 659902:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='EUC-KR' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
-<!-- English Revision: 105989:1673917 (outdated) -->
+<!-- English Revision: 105989:1673930 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
-<!-- English Revision: 1132802:1673917 (outdated) -->
+<!-- English Revision: 1132802:1673930 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>
<VirtualHost 111.22.33.44>
ServerName www.commercial.example.com
-
+
CustomLog logs/access_log.commercial vcommon
-
+
VirtualDocumentRoot "/www/commercial/%0/docs"
VirtualScriptAlias "/www/commercial/%0/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.45>
ServerName www.homepages.example.com
-
+
CustomLog logs/access_log.homepages vcommon
-
+
VirtualDocumentRoot "/www/homepages/%0/docs"
ScriptAlias "/cgi-bin/" "/www/std-cgi/"
</VirtualHost></pre>
<VirtualHost 111.22.33.44>
ServerName www.commercial.example.com
-
+
CustomLog logs/access_log.commercial vcommon
-
+
VirtualDocumentRoot "/www/commercial/%0/docs"
VirtualScriptAlias "/www/commercial/%0/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.45>
ServerName www.homepages.example.com
-
+
CustomLog logs/access_log.homepages vcommon
-
+
VirtualDocumentRoot "/www/homepages/%0/docs"
ScriptAlias "/cgi-bin/" "/www/std-cgi/"
</VirtualHost>
compare the <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> and <code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> directives to the server name
present in the request.</p>
- <p>If you omit the <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>
+ <p>If you omit the <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>
directive from any name-based virtual host, the server will default
to a fully qualified domain name (FQDN) derived from the system hostname.
This implicitly set server name can lead to counter-intuitive virtual host
matching and is discouraged.</p>
-
+
<h3><a name="defaultvhost" id="defaultvhost">The default name-based vhost for an IP and port combination </a></h3>
<p> If no matching ServerName or ServerAlias is found in the set of
virtual hosts containing the most specific matching IP address and port
<div class="note"><h3>ServerName inheritance</h3>
<p> It is best to always explicitly list a <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> in every name-based virtual host.</p>
- <p>If a <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> doesn't specify
- a <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>, a server name will be
- inherited from the base server configuration. If no server name was
+ <p>If a <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code> doesn't specify
+ a <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code>, a server name will be
+ inherited from the base server configuration. If no server name was
specified globally, one is detected at startup through reverse DNS resolution
of the first listening address. In either case, this inherited server name
will influence name-based virtual host resolution, so it is best to always
<pre class="prettyprint lang-config"><VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
- ServerAlias example.com
+ ServerAlias example.com
DocumentRoot "/www/domain"
</VirtualHost>
first have your DNS server properly configured to map those names to an IP
address associated with your server.</p>
- <p>Name-based virtual hosts for the best-matching set of <code class="directive"><a href="../mod/core.html#virtualhost"><virtualhost></a></code>s are processed
+ <p>Name-based virtual hosts for the best-matching set of <code class="directive"><a href="../mod/core.html#virtualhost"><virtualhost></a></code>s are processed
in the order they appear in the configuration. The first matching <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> or <code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code> is used, with no different precedence for wildcards
(nor for ServerName vs. ServerAlias). </p>
<p>The complete list of names in the <code class="directive"><a href="../mod/core.html#virtualhost">VirtualHost</a></code>
- directive are treated just like a (non wildcard)
+ directive are treated just like a (non wildcard)
<code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code>.</p>
<p>Finally, you can fine-tune the configuration of the virtual hosts
module="core">ServerAlias</directive> directives to the server name
present in the request.</p>
- <p>If you omit the <directive module="core">ServerName</directive>
+ <p>If you omit the <directive module="core">ServerName</directive>
directive from any name-based virtual host, the server will default
to a fully qualified domain name (FQDN) derived from the system hostname.
This implicitly set server name can lead to counter-intuitive virtual host
matching and is discouraged.</p>
-
+
<section id="defaultvhost"><title>The default name-based vhost for an IP and port combination </title>
<p> If no matching ServerName or ServerAlias is found in the set of
virtual hosts containing the most specific matching IP address and port
<note><title>ServerName inheritance</title>
<p> It is best to always explicitly list a <directive module="core"
>ServerName</directive> in every name-based virtual host.</p>
- <p>If a <directive module="core">VirtualHost</directive> doesn't specify
- a <directive module="core">ServerName</directive>, a server name will be
- inherited from the base server configuration. If no server name was
+ <p>If a <directive module="core">VirtualHost</directive> doesn't specify
+ a <directive module="core">ServerName</directive>, a server name will be
+ inherited from the base server configuration. If no server name was
specified globally, one is detected at startup through reverse DNS resolution
of the first listening address. In either case, this inherited server name
will influence name-based virtual host resolution, so it is best to always
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
- ServerAlias example.com
+ ServerAlias example.com
DocumentRoot "/www/domain"
</VirtualHost>
address associated with your server.</p>
<p>Name-based virtual hosts for the best-matching set of <directive
- type="section" module="core">virtualhost</directive>s are processed
+ type="section" module="core">virtualhost</directive>s are processed
in the order they appear in the configuration. The first matching <directive
module="core">ServerName</directive> or <directive module="core"
>ServerAlias</directive> is used, with no different precedence for wildcards
<p>The complete list of names in the <directive module="core"
>VirtualHost</directive>
- directive are treated just like a (non wildcard)
+ directive are treated just like a (non wildcard)
<directive module="core">ServerAlias</directive>.</p>
<p>Finally, you can fine-tune the configuration of the virtual hosts