static int example_handler(request_rec *r)
{
/* Set the appropriate content type */
- ap_set_content_type(r, "text/html");
+ ap_set_content_type(r, "text/html");
/* Print out the IP address of the client connecting to us: */
- ap_rprintf(r, "<h2>Hello, %s!</h2>", r->useragent_ip);
+ ap_rprintf(r, "<h2>Hello, %s!</h2>", r->useragent_ip);
/* If we were reached through a GET or a POST request, be happy, else sad. */
- if ( !strcmp(r->method, "POST") || !strcmp(r->method, "GET") ) {
- ap_rputs("You used a GET or a POST method, that makes us happy!<br/>", r);
+ if ( !strcmp(r->method, "POST") || !strcmp(r->method, "GET") ) {
+ ap_rputs("You used a GET or a POST method, that makes us happy!<br/>", r);
}
else {
- ap_rputs("You did not use POST or GET, that makes us sad :(<br/>", r);
+ ap_rputs("You did not use POST or GET, that makes us sad :(<br/>", r);
}
/* Lastly, if there was a query string, let's print that too! */
if (r->args) {
- ap_rprintf(r, "Your query string was: %s", r->args);
+ ap_rprintf(r, "Your query string was: %s", r->args);
}
return OK;
}
const char *digestType;
- /* Check that the "example-handler" handler is being called. */
- if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
+ /* Check that the "example-handler" handler is being called. */
+ if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
/* Figure out which file is being requested by removing the .sum from it */
filename = apr_pstrdup(r->pool, r->filename);
ap_parse_form_data(r, NULL, &POST, -1, 8192);
/* Set the appropriate content type */
- ap_set_content_type(r, "text/html");
+ ap_set_content_type(r, "text/html");
/* Print a title and some general information */
- ap_rprintf(r, "<h2>Information on %s:</h2>", filename);
- ap_rprintf(r, "<b>Size:</b> %u bytes<br/>", finfo.size);
+ ap_rprintf(r, "<h2>Information on %s:</h2>", filename);
+ ap_rprintf(r, "<b>Size:</b> %u bytes<br/>", finfo.size);
/* Get the digest type the client wants to see */
- digestType = apr_table_get(GET, "digest");
- if (!digestType) digestType = "MD5";
+ digestType = apr_table_get(GET, "digest");
+ if (!digestType) digestType = "MD5";
rc = apr_file_open(&file, filename, APR_READ, APR_OS_DEFAULT, r->pool);
if (rc == APR_SUCCESS) {
/* Are we trying to calculate the MD5 or the SHA1 digest? */
- if (!strcasecmp(digestType, "md5")) {
+ if (!strcasecmp(digestType, "md5")) {
/* Calculate the MD5 sum of the file */
union {
char chr[16];
apr_md5_final(digest.chr, &md5);
/* Print out the MD5 digest */
- ap_rputs("<b>MD5: </b><code>", r);
+ ap_rputs("<b>MD5: </b><code>", r);
for (n = 0; n < APR_MD5_DIGESTSIZE/4; n++) {
- ap_rprintf(r, "%08x", digest.num[n]);
+ ap_rprintf(r, "%08x", digest.num[n]);
}
- ap_rputs("</code>", r);
+ ap_rputs("</code>", r);
/* Print a link to the SHA1 version */
- ap_rputs("<br/><a href='?digest=sha1'>View the SHA1 hash instead</a>", r);
+ ap_rputs("<br/><a href='?digest=sha1'>View the SHA1 hash instead</a>", r);
}
else {
/* Calculate the SHA1 sum of the file */
apr_sha1_final(digest.chr, &sha1);
/* Print out the SHA1 digest */
- ap_rputs("<b>SHA1: </b><code>", r);
+ ap_rputs("<b>SHA1: </b><code>", r);
for (n = 0; n < APR_SHA1_DIGESTSIZE/4; n++) {
- ap_rprintf(r, "%08x", digest.num[n]);
+ ap_rprintf(r, "%08x", digest.num[n]);
}
- ap_rputs("</code>", r);
+ ap_rputs("</code>", r);
/* Print a link to the MD5 version */
- ap_rputs("<br/><a href='?digest=md5'>View the MD5 hash instead</a>", r);
+ ap_rputs("<br/><a href='?digest=md5'>View the MD5 hash instead</a>", r);
}
apr_file_close(file);
</p>
<highlight language="config">
RewriteEngine On
-RewriteCond %{REQUEST_URI} ^/foo/bar
-RewriteRule ^/foo/bar/(.*)$ /foobar?page=$1
+RewriteCond "%{REQUEST_URI}" "^/foo/bar"
+RewriteRule "^/foo/bar/(.*)$" "/foobar?page=$1"
</highlight>
<p>
Each of these configuration directives are handled by a separate function,
static int example_handler(request_rec *r)
{
- if (!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config.enabled);
- ap_rprintf(r, "Path: %s\n", config.path);
- ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
+ if (!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config.enabled);
+ ap_rprintf(r, "Path: %s\n", config.path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
return OK;
}
static void register_hooks(apr_pool_t *pool)
{
config.enabled = 1;
- config.path = "/foo/bar";
+ config.path = "/foo/bar";
config.typeOfAction = 0x00;
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
our configuration:
</p>
<highlight language="config">
-<Location /example>
+<Location "/example">
SetHandler example-handler
</Location>
</highlight>
Our directive handlers:
==============================================================================
*/
-/* Handler for the "exampleEnabled" directive */
+/* Handler for the "exampleEnabled" directive */
const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
{
- if(!strcasecmp(arg, "on")) config.enabled = 1;
+ if(!strcasecmp(arg, "on")) config.enabled = 1;
else config.enabled = 0;
return NULL;
}
-/* Handler for the "examplePath" directive */
+/* Handler for the "examplePath" directive */
const char *example_set_path(cmd_parms *cmd, void *cfg, const char *arg)
{
config.path = arg;
return NULL;
}
-/* Handler for the "exampleAction" directive */
+/* Handler for the "exampleAction" directive */
/* Let's pretend this one takes one argument (file or db), and a second (deny or allow), */
/* and we store it in a bit-wise manner. */
const char *example_set_action(cmd_parms *cmd, void *cfg, const char *arg1, const char *arg2)
{
- if(!strcasecmp(arg1, "file")) config.typeOfAction = 0x01;
+ if(!strcasecmp(arg1, "file")) config.typeOfAction = 0x01;
else config.typeOfAction = 0x02;
- if(!strcasecmp(arg2, "deny")) config.typeOfAction += 0x10;
+ if(!strcasecmp(arg2, "deny")) config.typeOfAction += 0x10;
else config.typeOfAction += 0x20;
return NULL;
}
*/
static const command_rec example_directives[] =
{
- AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF, "Enable or disable mod_example"),
- AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path to whatever"),
- AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF, "Special action value!"),
+ AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF, "Enable or disable mod_example"),
+ AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path to whatever"),
+ AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF, "Special action value!"),
{ NULL }
};
/*
*/
static int example_handler(request_rec *r)
{
- if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config.enabled);
- ap_rprintf(r, "Path: %s\n", config.path);
- ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
+ if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config.enabled);
+ ap_rprintf(r, "Path: %s\n", config.path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config.typeOfAction);
return OK;
}
static void register_hooks(apr_pool_t *pool)
{
config.enabled = 1;
- config.path = "/foo/bar";
+ config.path = "/foo/bar";
config.typeOfAction = 3;
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
configuration set up for mod_rewrite:
</p>
<highlight language="config">
-<Directory "/var/www">
- RewriteCond %{HTTP_HOST} ^example.com$
- RewriteRule (.*) http://www.example.com/$1
+<Directory "/var/www">
+ RewriteCond "%{HTTP_HOST}" "^example.com$"
+ RewriteRule "(.*)" "http://www.example.com/$1"
</Directory>
-<Directory "/var/www/sub">
- RewriteRule ^foobar$ index.php?foobar=true
+<Directory "/var/www/sub">
+ RewriteRule "^foobar$" "index.php?foobar=true"
</Directory>
</highlight>
<p>
where you have a parent configuration and a child, such as the following:
</p>
<highlight language="config">
-<Directory "/var/www">
+<Directory "/var/www">
ExampleEnabled On
- ExamplePath /foo/bar
+ ExamplePath "/foo/bar"
ExampleAction file allow
</Directory>
-<Directory "/var/www/subdir">
+<Directory "/var/www/subdir">
ExampleAction file deny
</Directory>
</highlight>
how the module works:
</p>
<highlight language="config">
-<Location "/a">
+<Location "/a">
SetHandler example-handler
ExampleEnabled on
- ExamplePath "/foo/bar"
+ ExamplePath "/foo/bar"
ExampleAction file allow
</Location>
-<Location "/a/b">
+<Location "/a/b">
ExampleAction file deny
ExampleEnabled off
</Location>
-<Location "/a/b/c">
+<Location "/a/b/c">
ExampleAction db deny
- ExamplePath "/foo/bar/baz"
+ ExamplePath "/foo/bar/baz"
ExampleEnabled on
</Location>
</highlight>
static const command_rec directives[] =
{
- AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, ACCESS_CONF, "Enable or disable mod_example"),
- AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever"),
- AP_INIT_TAKE2("exampleAction", example_set_action, NULL, ACCESS_CONF, "Special action value!"),
+ AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, ACCESS_CONF, "Enable or disable mod_example"),
+ AP_INIT_TAKE1("examplePath", example_set_path, NULL, ACCESS_CONF, "The path to whatever"),
+ AP_INIT_TAKE2("exampleAction", example_set_action, NULL, ACCESS_CONF, "Special action value!"),
{ NULL }
};
*/
static int example_handler(request_rec *r)
{
- if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
+ if(!r->handler || strcmp(r->handler, "example-handler")) return(DECLINED);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *config = (example_config *) ap_get_module_config(r->per_dir_config, &example_module);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- ap_set_content_type(r, "text/plain");
- ap_rprintf(r, "Enabled: %u\n", config->enabled);
- ap_rprintf(r, "Path: %s\n", config->path);
- ap_rprintf(r, "TypeOfAction: %x\n", config->typeOfAction);
- ap_rprintf(r, "Context: %s\n", config->context);
+ ap_set_content_type(r, "text/plain");
+ ap_rprintf(r, "Enabled: %u\n", config->enabled);
+ ap_rprintf(r, "Path: %s\n", config->path);
+ ap_rprintf(r, "TypeOfAction: %x\n", config->typeOfAction);
+ ap_rprintf(r, "Context: %s\n", config->context);
return OK;
}
/*
=======================================================================================================================
- Handler for the "exampleEnabled" directive
+ Handler for the "exampleEnabled" directive
=======================================================================================================================
*/
const char *example_set_enabled(cmd_parms *cmd, void *cfg, const char *arg)
if(conf)
{
- if(!strcasecmp(arg, "on"))
+ if(!strcasecmp(arg, "on"))
conf->enabled = 1;
else
conf->enabled = 0;
/*
=======================================================================================================================
- Handler for the "examplePath" directive
+ Handler for the "examplePath" directive
=======================================================================================================================
*/
const char *example_set_path(cmd_parms *cmd, void *cfg, const char *arg)
/*
=======================================================================================================================
- Handler for the "exampleAction" directive ;
+ Handler for the "exampleAction" directive ;
Let's pretend this one takes one argument (file or db), and a second (deny or allow), ;
and we store it in a bit-wise manner.
=======================================================================================================================
if(conf)
{
{
- if(!strcasecmp(arg1, "file"))
+ if(!strcasecmp(arg1, "file"))
conf->typeOfAction = 0x01;
else
conf->typeOfAction = 0x02;
- if(!strcasecmp(arg2, "deny"))
+ if(!strcasecmp(arg2, "deny"))
conf->typeOfAction += 0x10;
else
conf->typeOfAction += 0x20;
*/
void *create_dir_conf(apr_pool_t *pool, char *context)
{
- context = context ? context : "Newly created configuration";
+ context = context ? context : "Newly created configuration";
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *cfg = apr_pcalloc(pool, sizeof(example_config));
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
example_config *base = (example_config *) BASE;
example_config *add = (example_config *) ADD;
- example_config *conf = (example_config *) create_dir_conf(pool, "Merged configuration");
+ example_config *conf = (example_config *) create_dir_conf(pool, "Merged configuration");
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
conf->enabled = (add->enabled == 0) ? base->enabled : add->enabled;
int i;
for (i = 0; &formData[i]; i++) {
if (formData[i].key && formData[i].value) {
- ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value);
+ ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value);
} else if (formData[i].key) {
- ap_rprintf(r, "%s\n", formData[i].key);
+ ap_rprintf(r, "%s\n", formData[i].key);
} else if (formData[i].value) {
- ap_rprintf(r, "= %s\n", formData[i].value);
+ ap_rprintf(r, "= %s\n", formData[i].value);
} else {
break;
}
fields = apr_table_elts(r->headers_in);
e = (apr_table_entry_t *) fields->elts;
for(i = 0; i < fields->nelts; i++) {
- ap_rprintf(r, "%s: %s\n", e[i].key, e[i].val);
+ ap_rprintf(r, "%s: %s\n", e[i].key, e[i].val);
}
return OK;
}
/*~~~~~~~~~~~~~~~~*/
if(util_read(r, &buffer, &size) == OK) {
- ap_rprintf(r, "We read a request body that was %" APR_OFF_T_FMT " bytes long", size);
+ ap_rprintf(r, "We read a request body that was %" APR_OFF_T_FMT " bytes long", size);
}
return OK;
}
# This is a misconfiguration example, do not use on your server
<VirtualHost www.example.dom>
ServerAdmin webgirl@example.dom
- DocumentRoot /www/example
+ DocumentRoot "/www/example"
</VirtualHost>
</highlight>
# This is a misconfiguration example, do not use on your server
<VirtualHost 192.0.2.1>
ServerAdmin webgirl@example.dom
- DocumentRoot /www/example
+ DocumentRoot "/www/example"
</VirtualHost>
</highlight>
<VirtualHost 192.0.2.1>
ServerName www.example.dom
ServerAdmin webgirl@example.dom
- DocumentRoot /www/example
+ DocumentRoot "/www/example"
</VirtualHost>
</highlight>
</section>
<highlight language="config">
<VirtualHost www.example1.dom>
ServerAdmin webgirl@example1.dom
- DocumentRoot /www/example1
+ DocumentRoot "/www/example1"
</VirtualHost>
<VirtualHost www.example2.dom>
ServerAdmin webguy@example2.dom
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
</VirtualHost>
</highlight>
SetEnvIf Referer "^http://www\.example\.com/" local_referal
# Allow browsers that do not send Referer info
SetEnvIf Referer "^$" local_referal
-<Directory /web/images>
+<Directory "/web/images">
Require env local_referal
</Directory>
</highlight>
<highlight language="config">
# Compare the host name to example.com and redirect to www.example.com if it matches
<If "%{HTTP_HOST} == 'example.com'">
- Redirect permanent / http://www.example.com/
+ Redirect permanent "/" "http://www.example.com/"
</If>
# Force text/plain if requesting a file with the query string contains 'forcetext'
</If>
# Check result of URI mapping by running in Directory context with -f
-<Directory /var/www>
+<Directory "/var/www">
AddEncoding x-gzip gz
<If "-f '%{REQUEST_FILENAME}.unzipme' && ! %{HTTP:Accept-Encoding} =~ /gzip/">
SetOutputFilter INFLATE
filename extensions.</p>
<highlight language="config">
-<Directory /web/htdocs/asis>
+<Directory "/web/htdocs/asis">
SetHandler send-as-is
</Directory>
</highlight>
<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
following directives, either placed in the file
<code>/usr/local/apache/htdocs/secret/.htaccess</code>, or
placed in <code>httpd.conf</code> inside a <Directory
- /usr/local/apache/htdocs/secret> section.</p>
+ "/usr/local/apache/htdocs/secret"> section.</p>
<highlight language="config">
AuthType Basic
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
-AuthUserFile /usr/local/apache/passwd/passwords
+AuthUserFile "/usr/local/apache/passwd/passwords"
Require user rbowen
</highlight>
AuthName "By Invitation Only"
# Optional line:
AuthBasicProvider file
-AuthUserFile /usr/local/apache/passwd/passwords
-AuthGroupFile /usr/local/apache/passwd/groups
+AuthUserFile "/usr/local/apache/passwd/passwords"
+AuthGroupFile "/usr/local/apache/passwd/groups"
Require group GroupName
</highlight>
<p>To select a dbm file rather than a text file, for example:</p>
<highlight language="config">
-<Directory /www/docs/private>
+<Directory "/www/docs/private">
AuthName "Private"
AuthType Basic
AuthBasicProvider dbm
- AuthDBMUserFile /www/passwords/passwd.dbm
+ AuthDBMUserFile "/www/passwords/passwd.dbm"
Require valid-user
</Directory>
</highlight>
file and LDAP based authentication providers are being used.</p>
<highlight language="config">
-<Directory /www/docs/private>
+<Directory "/www/docs/private">
AuthName "Private"
AuthType Basic
AuthBasicProvider file ldap
- AuthUserFile /usr/local/apache/passwd/passwords
+ AuthUserFile "/usr/local/apache/passwd/passwords"
AuthLDAPURL ldap://ldaphost/o=yourorg
Require valid-user
</Directory>
authorization as well as LDAP group authorization is being used.</p>
<highlight language="config">
-<Directory /www/docs/private>
+<Directory "/www/docs/private">
AuthName "Private"
AuthType Basic
AuthBasicProvider file
- AuthUserFile /usr/local/apache/passwd/passwords
+ AuthUserFile "/usr/local/apache/passwd/passwords"
AuthLDAPURL ldap://ldaphost/o=yourorg
- AuthGroupFile /usr/local/apache/passwd/groups
+ AuthGroupFile "/usr/local/apache/passwd/groups"
Require group GroupName
Require ldap-group cn=mygroup,o=yourorg
</Directory>
directive looks like:</p>
<highlight language="config">
- ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
+ ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/"
</highlight>
<p>The example shown is from your default <code>httpd.conf</code>
directory:</p>
<highlight language="config">
-<Directory /usr/local/apache2/htdocs/somedir>
+<Directory "/usr/local/apache2/htdocs/somedir">
Options +ExecCGI
</Directory>
</highlight>
following configuration.</p>
<highlight language="config">
-<Directory /home/*/public_html>
+<Directory "/home/*/public_html">
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
program, you can use the following.</p>
<highlight language="config">
-<Directory /home/*/public_html/cgi-bin>
+<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
if you would rather call the file <code>.config</code> then you
can put the following in your server configuration file:</p>
- <highlight language="config">AccessFileName .config</highlight>
+ <highlight language="config">
+AccessFileName ".config"
+ </highlight>
</note>
<p>In general, <code>.htaccess</code> files use the same syntax as
<p>Note that it is completely equivalent to put a <code>.htaccess</code>
file in a directory <code>/www/htdocs/example</code> containing a
directive, and to put that same directive in a Directory section
- <code><Directory /www/htdocs/example></code> in your main server
+ <code><Directory "/www/htdocs/example"></code> in your main server
configuration:</p>
<p><code>.htaccess</code> file in <code>/www/htdocs/example</code>:</p>
<example><title>Contents of .htaccess file in
<code>/www/htdocs/example</code></title>
- <highlight language="config">AddType text/example .exm</highlight>
+ <highlight language="config">
+AddType text/example ".exm"
+ </highlight>
</example>
<example><title>Section from your <code>httpd.conf</code>
file</title>
<highlight language="config">
-<Directory /www/htdocs/example>
- AddType text/example .exm
+<Directory "/www/htdocs/example">
+ AddType text/example ".exm"
</Directory>
</highlight>
</example>
by setting the <directive module="core">AllowOverride</directive>
directive to <code>none</code>:</p>
- <highlight language="config">AllowOverride None</highlight>
+ <highlight language="config">
+AllowOverride None
+ </highlight>
</section>
<section id="how"><title>How directives are applied</title>
<p>In the directory <code>/www/htdocs/example1</code> we have a
<code>.htaccess</code> file containing the following:</p>
- <highlight language="config">Options +ExecCGI</highlight>
+ <highlight language="config">
+Options +ExecCGI
+ </highlight>
<p>(Note: you must have "<code>AllowOverride Options</code>" in effect
to permit the use of the "<directive
<p>In the directory <code>/www/htdocs/example1/example2</code> we have
a <code>.htaccess</code> file containing:</p>
- <highlight language="config">Options Includes</highlight>
+ <highlight language="config">
+Options Includes
+ </highlight>
<p>Because of this second <code>.htaccess</code> file, in the directory
<code>/www/htdocs/example1/example2</code>, CGI execution is not
<code>.htaccess</code> you can use:</p>
<highlight language="config">
-<Directory /www/htdocs>
+<Directory "/www/htdocs">
AllowOverride All
</Directory>
-<Location />
+<Location "/">
Options +IncludesNoExec -ExecCGI<br />
</Location>
</highlight>
<highlight language="config">
AuthType Basic
AuthName "Password Required"
-AuthUserFile /www/passwords/password.file
-AuthGroupFile /www/passwords/group.file
+AuthUserFile "/www/passwords/password.file"
+AuthGroupFile "/www/passwords/group.file"
Require group admins
</highlight>
<highlight language="config">
# In httpd.conf
-RewriteRule ^/images/(.+)\.jpg /images/$1.png
+RewriteRule "^/images/(.+)\.jpg" "/images/$1.png"
# In .htaccess in root dir
-RewriteRule ^images/(.+)\.jpg images/$1.png
+RewriteRule "^images/(.+)\.jpg" "images/$1.png"
# In .htaccess in images/
-RewriteRule ^(.+)\.jpg $1.png
+RewriteRule "^(.+)\.jpg" "$1.png"
</highlight>
<p>In a <code>.htaccess</code> in your document directory, the leading
cgi-enabled.</p>
<highlight language="config">
-<Directory /home/*/public_html/cgi-bin/>
+<Directory "/home/*/public_html/cgi-bin/">
Options ExecCGI
SetHandler cgi-script
</Directory>
using these directives, if possible.</p>
<p>Note that it's possible to scope the directives, such as
- within a <code><Location /server-status></code> section.
+ within a <code><Location "/server-status"></code> section.
In this case the DNS lookups are only performed on requests
matching the criteria. Here's an example which disables lookups
except for <code>.html</code> and <code>.cgi</code> files:</p>
filename component. For example, if you had:</p>
<highlight language="config">
-DocumentRoot /www/htdocs
-<Directory />
+DocumentRoot "/www/htdocs"
+<Directory "/">
Options SymLinksIfOwnerMatch
</Directory>
</highlight>
security checking you can do something like this:</p>
<highlight language="config">
-DocumentRoot /www/htdocs
-<Directory />
+DocumentRoot "/www/htdocs"
+<Directory "/">
Options FollowSymLinks
</Directory>
-<Directory /www/htdocs>
+<Directory "/www/htdocs">
Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>
</highlight>
example,</p>
<highlight language="config">
-DocumentRoot /www/htdocs
-<Directory />
+DocumentRoot "/www/htdocs"
+<Directory "/">
AllowOverride all
</Directory>
</highlight>
<p>In the server configuration file, put</p>
<highlight language="config">
-<Directory />
+<Directory "/">
AllowOverride None
</Directory>
</highlight>
configuration:</p>
<highlight language="config">
-<Directory />
+<Directory "/">
Require all denied
</Directory>
</highlight>
allow access only in those areas you wish. For example,</p>
<highlight language="config">
-<Directory /usr/users/*/public_html>
+<Directory "/usr/users/*/public_html">
Require all granted
</Directory>
-<Directory /usr/local/httpd>
+<Directory "/usr/local/httpd">
Require all granted
</Directory>
</highlight>
<p>Pay particular attention to the interactions of <directive
module="core">Location</directive> and <directive
module="core">Directory</directive> directives; for instance, even
- if <code><Directory /></code> denies access, a <code>
- <Location /></code> directive might overturn it.</p>
+ if <code><Directory "/"></code> denies access, a <code>
+ <Location "/"></code> directive might overturn it.</p>
<p>Also be wary of playing games with the <directive
module="mod_userdir">UserDir</directive> directive; setting it to
<code>/usr/local/.acl</code> and <code>/usr/local/web/.acl</code>
for directives, unless they have been disabled with</p>
- <pre class="prettyprint lang-config"><Directory />
+ <pre class="prettyprint lang-config"><Directory "/">
AllowOverride None
</Directory></pre>
<div class="note"><p>For security and performance reasons, do not set
<code>AllowOverride</code> to anything other than <code>None</code>
- in your <code><Directory /></code> block. Instead, find (or
+ in your <code><Directory "/"></code> block. Instead, find (or
create) the <code><Directory></code> block that refers to the
directory where you're actually planning to place a
<code>.htaccess</code> file.</p>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enclose a group of directives that apply only to the
named file-system directory, sub-directories, and their contents.</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Directory <var>directory-path</var>>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Directory "<var>directory-path</var>">
... </Directory></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
any single character, and <code>*</code> matches any sequences of
characters. You may also use <code>[]</code> character ranges. None
of the wildcards match a `/' character, so <code><Directory
- /*/public_html></code> will not match
+ "/*/public_html"></code> will not match
<code>/home/user/public_html</code>, but <code><Directory
- /home/*/public_html></code> will match. Example:</p>
+ "/home/*/public_html"></code> will match. Example:</p>
<pre class="prettyprint lang-config"><Directory "/usr/local/httpd/htdocs">
Options Indexes FollowSymLinks
first, interspersed with the directives from the <a href="#accessfilename">.htaccess</a> files. For example,
with</p>
- <pre class="prettyprint lang-config"><Directory />
+ <pre class="prettyprint lang-config"><Directory "/">
AllowOverride None
</Directory>
be applied.</p>
<p><strong>Note that the default access for
- <code><Directory /></code> is to permit all access.
+ <code><Directory "/"></code> is to permit all access.
This means that Apache httpd will serve any file mapped from an URL. It is
recommended that you change this with a block such
as</strong></p>
- <pre class="prettyprint lang-config"><Directory />
+ <pre class="prettyprint lang-config"><Directory "/">
Require all denied
</Directory></pre>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enclose directives that apply to
the contents of file-system directories matching a regular expression.</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><DirectoryMatch <var>regex</var>>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><DirectoryMatch "<var>regex</var>">
... </DirectoryMatch></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
-<pre class="prettyprint lang-config"><DirectoryMatch ^/var/www/combined/(?<sitename>[^/]+)>
+<pre class="prettyprint lang-config"><DirectoryMatch "^/var/www/combined/(?<sitename>[^/]+)">
Require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</DirectoryMatch></pre>
<pre class="prettyprint lang-config">ErrorDocument 404 /cgi-bin/bad_urls.pl
-<Directory /web/docs>
+<Directory "/web/docs">
ErrorDocument 404 default
</Directory></pre>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Contains directives that apply to matched
filenames</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Files <var>filename</var>> ... </Files></code></td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Files "<var>filename</var>"> ... </Files></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Contains directives that apply to regular-expression matched
filenames</td></tr>
-<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><FilesMatch <var>regex</var>> ... </FilesMatch></code></td></tr>
+<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><FilesMatch "<var>regex</var>"> ... </FilesMatch></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
-<pre class="prettyprint lang-config"><FilesMatch ^(?<sitename>[^/]+)>
+<pre class="prettyprint lang-config"><FilesMatch "^(?<sitename>[^/]+)">
require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</FilesMatch></pre>
by using the value of <code>None</code>:</p>
<pre class="prettyprint lang-config"># force all files to be image/gif:
-<Location /images>
+<Location "/images">
ForceType image/gif
</Location>
# but normal mime-type associations here:
-<Location /images/mixed>
+<Location "/images/mixed">
ForceType None
</Location></pre>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Applies the enclosed directives only to matching
URLs</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><Location
- <var>URL-path</var>|<var>URL</var>> ... </Location></code></td></tr>
+ "<var>URL-path</var>|<var>URL</var>"> ... </Location></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr>
/private1, /private1/ and /private1/file.txt will have the enclosed
directives applied, but /private1other would not.
</p>
- <pre class="prettyprint lang-config"><Location /private1>
+ <pre class="prettyprint lang-config"><Location "/private1">
# ...
</Location></pre>
/private2/ and /private2/file.txt will have the enclosed
directives applied, but /private2 and /private2other would not.
</p>
- <pre class="prettyprint lang-config"><Location /private2<em>/</em>>
+ <pre class="prettyprint lang-config"><Location "/private2<em>/</em>">
# ...
</Location></pre>
<p>Use <code class="directive"><Location></code> to apply
directives to content that lives outside the filesystem. For
content that lives in the filesystem, use <code class="directive"><a href="#directory"><Directory></a></code> and <code class="directive"><a href="#files"><Files></a></code>. An exception is
- <code><Location /></code>, which is an easy way to
+ <code><Location "/"></code>, which is an easy way to
apply a configuration to the entire server.</p>
</div>
directive. For example, to enable status requests, but allow them
only from browsers at <code>example.com</code>, you might use:</p>
- <pre class="prettyprint lang-config"><Location /status>
+ <pre class="prettyprint lang-config"><Location "/status">
SetHandler server-status
Require host example.com
</Location></pre>
directive and the regex version of <code class="directive"><Location></code> require you to explicitly specify multiple
slashes if that is your intention.</p>
- <p>For example, <code><LocationMatch ^/abc></code> would match
+ <p>For example, <code><LocationMatch "^/abc"></code> would match
the request URL <code>/abc</code> but not the request URL <code>
//abc</code>. The (non-regex) <code class="directive"><Location></code> directive behaves similarly when used for
proxy requests. But when (non-regex) <code class="directive"><Location></code> is used for non-proxy requests it will
implicitly match multiple slashes with a single slash. For example,
- if you specify <code><Location /abc/def></code> and the
+ if you specify <code><Location "/abc/def"></code> and the
request is to <code>/abc//def</code> then it will match.</p>
</div>
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Applies the enclosed directives only to regular-expression
matching URLs</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><LocationMatch
- <var>regex</var>> ... </LocationMatch></code></td></tr>
+ "<var>regex</var>"> ... </LocationMatch></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr>
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
-<pre class="prettyprint lang-config"><LocationMatch ^/combined/(?<sitename>[^/]+)>
+<pre class="prettyprint lang-config"><LocationMatch "^/combined/(?<sitename>[^/]+)">
require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</LocationMatch></pre>
<p>You could also use this directive to configure a particular
handler for files with a particular file extension. For example:</p>
- <pre class="prettyprint lang-config"><FilesMatch \.php$>
+ <pre class="prettyprint lang-config"><FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch></pre>
for directives, unless they have been disabled with</p>
<highlight language="config">
-<Directory />
+<Directory "/">
AllowOverride None
</Directory>
</highlight>
<note><p>For security and performance reasons, do not set
<code>AllowOverride</code> to anything other than <code>None</code>
- in your <code><Directory /></code> block. Instead, find (or
+ in your <code><Directory "/"></code> block. Instead, find (or
create) the <code><Directory></code> block that refers to the
directory where you're actually planning to place a
<code>.htaccess</code> file.</p>
Define SSL
</IfDefine>
-DocumentRoot /var/www/${servername}/htdocs
+DocumentRoot "/var/www/${servername}/htdocs"
</highlight>
<p>Variable names may not contain colon ":" characters, to avoid clashes
<name>Directory</name>
<description>Enclose a group of directives that apply only to the
named file-system directory, sub-directories, and their contents.</description>
-<syntax><Directory <var>directory-path</var>>
+<syntax><Directory "<var>directory-path</var>">
... </Directory></syntax>
<contextlist><context>server config</context><context>virtual host</context>
</contextlist>
any single character, and <code>*</code> matches any sequences of
characters. You may also use <code>[]</code> character ranges. None
of the wildcards match a `/' character, so <code><Directory
- /*/public_html></code> will not match
+ "/*/public_html"></code> will not match
<code>/home/user/public_html</code>, but <code><Directory
- /home/*/public_html></code> will match. Example:</p>
+ "/home/*/public_html"></code> will match. Example:</p>
<highlight language="config">
<Directory "/usr/local/httpd/htdocs">
with</p>
<highlight language="config">
-<Directory />
+<Directory "/">
AllowOverride None
</Directory>
be applied.</p>
<p><strong>Note that the default access for
- <code><Directory /></code> is to permit all access.
+ <code><Directory "/"></code> is to permit all access.
This means that Apache httpd will serve any file mapped from an URL. It is
recommended that you change this with a block such
as</strong></p>
<highlight language="config">
-<Directory />
+<Directory "/">
Require all denied
</Directory>
</highlight>
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<DirectoryMatch ^/var/www/combined/(?<sitename>[^/]+)>
+<DirectoryMatch "^/var/www/combined/(?<sitename>[^/]+)">
Require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</DirectoryMatch>
</highlight>
<description>Directory that forms the main document tree visible
from the web</description>
<syntax>DocumentRoot <var>directory-path</var></syntax>
-<default>DocumentRoot /usr/local/apache/htdocs</default>
+<default>DocumentRoot "/usr/local/apache/htdocs"</default>
<contextlist><context>server config</context><context>virtual host</context>
</contextlist>
<highlight language="config">
ErrorDocument 404 /cgi-bin/bad_urls.pl
-<Directory /web/docs>
+<Directory "/web/docs">
ErrorDocument 404 default
</Directory>
</highlight>
<name>Files</name>
<description>Contains directives that apply to matched
filenames</description>
-<syntax><Files <var>filename</var>> ... </Files></syntax>
+<syntax><Files "<var>filename</var>"> ... </Files></syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context>
</contextlist>
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<FilesMatch ^(?<sitename>[^/]+)>
+<FilesMatch "^(?<sitename>[^/]+)">
require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</FilesMatch>
</highlight>
<highlight language="config">
# force all files to be image/gif:
-<Location /images>
+<Location "/images">
ForceType image/gif
</Location>
# but normal mime-type associations here:
-<Location /images/mixed>
+<Location "/images/mixed">
ForceType None
</Location>
</highlight>
<description>Applies the enclosed directives only to matching
URLs</description>
<syntax><Location
- <var>URL-path</var>|<var>URL</var>> ... </Location></syntax>
+ "<var>URL-path</var>|<var>URL</var>"> ... </Location></syntax>
<contextlist><context>server config</context><context>virtual host</context>
</contextlist>
directives applied, but /private1other would not.
</p>
<highlight language="config">
-<Location /private1>
+<Location "/private1">
# ...
</Location>
</highlight>
directives applied, but /private2 and /private2other would not.
</p>
<highlight language="config">
-<Location /private2<em>/</em>>
+<Location "/private2<em>/</em>">
# ...
</Location>
</highlight>
content that lives in the filesystem, use <directive
type="section" module="core">Directory</directive> and <directive
type="section" module="core">Files</directive>. An exception is
- <code><Location /></code>, which is an easy way to
+ <code><Location "/"></code>, which is an easy way to
apply a configuration to the entire server.</p>
</note>
only from browsers at <code>example.com</code>, you might use:</p>
<highlight language="config">
-<Location /status>
+<Location "/status">
SetHandler server-status
Require host example.com
</Location>
>Location</directive> require you to explicitly specify multiple
slashes if that is your intention.</p>
- <p>For example, <code><LocationMatch ^/abc></code> would match
+ <p>For example, <code><LocationMatch "^/abc"></code> would match
the request URL <code>/abc</code> but not the request URL <code>
//abc</code>. The (non-regex) <directive type="section"
>Location</directive> directive behaves similarly when used for
proxy requests. But when (non-regex) <directive type="section"
>Location</directive> is used for non-proxy requests it will
implicitly match multiple slashes with a single slash. For example,
- if you specify <code><Location /abc/def></code> and the
+ if you specify <code><Location "/abc/def"></code> and the
request is to <code>/abc//def</code> then it will match.</p>
</note>
</usage>
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<LocationMatch ^/combined/(?<sitename>[^/]+)>
+<LocationMatch "^/combined/(?<sitename>[^/]+)">
require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</LocationMatch>
</highlight>
handler for files with a particular file extension. For example:</p>
<highlight language="config">
-<FilesMatch \.php$>
+<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
</highlight>
<highlight language="config">
<VirtualHost 10.1.2.3:80>
ServerAdmin webmaster@host.example.com
- DocumentRoot /www/docs/host.example.com
+ DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost [2001:db8::a00:20ff:fea7:ccea]:80>
ServerAdmin webmaster@host.example.com
- DocumentRoot /www/docs/host.example.com
+ DocumentRoot "/www/docs/host.example.com"
ServerName host.example.com
- ErrorLog logs/host.example.com-error_log
- TransferLog logs/host.example.com-access_log
+ ErrorLog "logs/host.example.com-error_log"
+ TransferLog "logs/host.example.com-access_log"
</VirtualHost>
</highlight>
<highlight language="config">
SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
-<Directory /docroot>
+<Directory "/docroot">
Order Deny,Allow
Deny from all
Allow from env=let_me_in
example,</p>
<highlight language="config">
-<Directory /www>
+<Directory "/www">
Order Allow,Deny
</Directory>
</highlight>
</p>
<highlight language="config">
-<Directory /var/www/private>
+<Directory "/var/www/private">
Require valid-user
</Directory>
-<Directory /var/www/private/public>
+<Directory "/var/www/private/public">
Allow from all
Satisfy Any
</Directory>
<highlight language="config">
# Files of a particular file extension
AddHandler my-file-type .xyz
-Action my-file-type /cgi-bin/program.cgi
+Action my-file-type "/cgi-bin/program.cgi"
</highlight>
</example>
<p>In this example, requests for files with a file extension of
virtual locations.</p>
<highlight language="config">
-<Location /news>
+<Location "/news">
SetHandler news-handler
- Action news-handler /cgi-bin/news.cgi virtual
+ Action news-handler "/cgi-bin/news.cgi" virtual
</Location>
</highlight>
</usage>
<highlight language="config">
# All GET requests go here
-Script GET /cgi-bin/search
+Script GET "/cgi-bin/search"
# A CGI PUT handler
-Script PUT /~bob/put.cgi
+Script PUT "/~bob/put.cgi"
</highlight>
</usage>
</directivesynopsis>
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>
configuration will work as expected:</p>
<highlight language="config">
-Alias /foo/bar /baz
-Alias /foo /gaq
+Alias "/foo/bar" "/baz"
+Alias "/foo" "/gaq"
</highlight>
<p>But if the above two directives were reversed in order, the
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>
file systems.</p>
<highlight language="config">
- Alias /image /ftp/pub/image
+ Alias "/image" "/ftp/pub/image"
</highlight>
<p>A request for <code>http://example.com/image/foo.gif</code> would cause
order to expand the alias. That is, if you use</p>
<highlight language="config">
- Alias /icons/ /usr/local/apache/icons/
+ Alias "/icons/" "/usr/local/apache/icons/"
</highlight>
- <p>then the url <code>/icons</code> will not be aliased, as it lacks
+ <p>then the URL <code>/icons</code> will not be aliased, as it lacks
that trailing /. Likewise, if you omit the slash on the
<var>URL-path</var> then you must also omit it from the
<var>file-path</var>.</p>
permit access to the target directory.</p>
<highlight language="config">
-Alias /image /ftp/pub/image
-<Directory /ftp/pub/image>
+Alias "/image" "/ftp/pub/image"
+<Directory "/ftp/pub/image">
Require all granted
</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
using <a href="../expr.html">expression syntax</a>.</p>
<highlight language="config">
-<Location /image>
- Alias /ftp/pub/image
+<Location "/image">
+ Alias "/ftp/pub/image"
</Location>
-<LocationMatch /error/(?<NUMBER>[0-9]+)>
- Alias /usr/local/apache/errors/%{env:MATCH_NUMBER}.html
+<LocationMatch "/error/(?<NUMBER>[0-9]+)">
+ Alias "/usr/local/apache/errors/%{env:MATCH_NUMBER}.html"
</LocationMatch>
</highlight>
use:</p>
<highlight language="config">
- AliasMatch ^/icons(/|$)(.*) /usr/local/apache/icons$1$2
+ AliasMatch "^/icons(/|$)(.*)" "/usr/local/apache/icons$1$2"
</highlight>
<p>The full range of <glossary ref="regex">regular expression</glossary>
matching of the URL-path:</p>
<highlight language="config">
- AliasMatch (?i)^/image(.*) /ftp/pub/image$1
+ AliasMatch "(?i)^/image(.*)" "/ftp/pub/image$1"
</highlight>
<p>One subtle difference
<p>For example, suppose you want to replace this with AliasMatch:</p>
<highlight language="config">
- Alias /image/ /ftp/pub/image/
+ Alias "/image/" "/ftp/pub/image/"
</highlight>
<p>This is NOT equivalent - don't do this! This will send all
requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
<highlight language="config">
- AliasMatch /image/ /ftp/pub/image/
+ AliasMatch "/image/" "/ftp/pub/image/"
</highlight>
<p>This is what you need to get the same effect:</p>
<highlight language="config">
- AliasMatch ^/image/(.*)$ /ftp/pub/image/$1
+ AliasMatch "^/image/(.*)$" "/ftp/pub/image/$1"
</highlight>
<p>Of course, there's no point in
serve different kinds of files from different directories:</p>
<highlight language="config">
- AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg<br/>
- AliasMatch ^/image/(.*)\.gif$ /files/gif.images/$1.gif
+ AliasMatch "^/image/(.*)\.jpg$" "/files/jpg.images/$1.jpg"<br/>
+ AliasMatch "^/image/(.*)\.gif$" "/files/gif.images/$1.gif"
</highlight>
<p>Multiple leading slashes in the requested URL are discarded
<highlight language="config">
# Redirect to a URL on a different host
-Redirect /service http://foo2.example.com/service
+Redirect "/service" "http://foo2.example.com/service"
# Redirect to a URL on the same host
-Redirect /one /two
+Redirect "/one" "/two"
</highlight>
<p>If the client requests <code>http://example.com/service/foo.txt</code>,
<code>send_error_response</code> in http_protocol.c).</p>
<highlight language="config">
-Redirect permanent /one http://example.com/two
-Redirect 303 /three http://example.com/other
+Redirect permanent "/one" "http://example.com/two"
+Redirect 303 "/three" "http://example.com/other"
</highlight>
<p>If the <directive>Redirect</directive> directive is used within a
interpreted using <a href="../expr.html">expression syntax</a>.</p>
<highlight language="config">
-<Location /one>
- Redirect permanent http://example.com/two
+<Location "/one">
+ Redirect permanent "http://example.com/two"
</Location><br />
-<Location /three>
- Redirect 303 http://example.com/other
+<Location "/three">
+ Redirect 303 "http://example.com/other"
</Location><br />
-<LocationMatch /error/(?<NUMBER>[0-9]+)>
- Redirect permanent http://example.com/errors/%{env:MATCH_NUMBER}.html
+<LocationMatch "/error/(?<NUMBER>[0-9]+)">
+ Redirect permanent "http://example.com/errors/%{env:MATCH_NUMBER}.html"
</LocationMatch><br />
</highlight>
another server, one might use:</p>
<highlight language="config">
- RedirectMatch (.*)\.gif$ http://other.example.com$1.jpg
+ RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg"
</highlight>
<p>The considerations related to the difference between
pathname in the local filesystem.</p>
<highlight language="config">
- ScriptAlias /cgi-bin/ /web/cgi-bin/
+ ScriptAlias "/cgi-bin/" "/web/cgi-bin/"
</highlight>
<p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
server to run the script <code>/web/cgi-bin/foo</code>. This configuration
is essentially equivalent to:</p>
<highlight language="config">
-Alias /cgi-bin/ /web/cgi-bin/
-<Location /cgi-bin >
+Alias "/cgi-bin/" "/web/cgi-bin/"
+<Location "/cgi-bin" >
SetHandler cgi-script
Options +ExecCGI
</Location>
a script or handler you have. For example:</p>
<highlight language="config">
- ScriptAlias /cgi-bin/ /web/cgi-handler.pl
+ ScriptAlias "/cgi-bin/" "/web/cgi-handler.pl"
</highlight>
<p>In this scenario all files requested in <code>/cgi-bin/</code> will be
module="core">SetHandler</directive>, and <directive
module="core">Options</directive> as in:
<highlight language="config">
-<Directory /usr/local/apache2/htdocs/cgi-bin >
+<Directory "/usr/local/apache2/htdocs/cgi-bin">
SetHandler cgi-script
Options ExecCGI
</Directory>
interpreted using <a href="../expr.html">expression syntax</a>.</p>
<highlight language="config">
-<Location /cgi-bin >
- ScriptAlias /web/cgi-bin/
+<Location "/cgi-bin">
+ ScriptAlias "/web/cgi-bin/"
</Location>
-<LocationMatch /cgi-bin/errors/(?<NUMBER>[0-9]+)>
- ScriptAlias /web/cgi-bin/errors/%{env:MATCH_NUMBER}.cgi
+<LocationMatch "/cgi-bin/errors/(?<NUMBER>[0-9]+)">
+ ScriptAlias "/web/cgi-bin/errors/%{env:MATCH_NUMBER}.cgi"
</LocationMatch><br />
</highlight>
might use:</p>
<highlight language="config">
- ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
+ ScriptAliasMatch "^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"
</highlight>
<p>As for AliasMatch, the full range of <glossary ref="rexex">regular
matching of the URL-path:</p>
<highlight language="config">
- ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
+ ScriptAliasMatch "(?i)^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"
</highlight>
<p>The considerations related to the difference between
</directivesynopsis>
</modulesynopsis>
-
used on an server. The most common configuration would be:</p>
<highlight language="config">
-<Location />
+<Location "/">
AllowMethods GET POST OPTIONS
</Location>
</highlight>
turn off <module>mod_allowmethods</module> in a deeper nested context:</p>
<highlight language="config">
-<Location /svn>
+<Location "/svn">
AllowMethods reset
</Location>
</highlight>
that the chosen provider module is present in the server.</p>
<example><title>Example</title>
<highlight language="config">
-<Location /secure>
+<Location "/secure">
AuthType basic
AuthName "private area"
AuthBasicProvider dbm
AuthDBMType SDBM
- AuthDBMUserFile /www/etc/dbmpasswd
+ AuthDBMUserFile "/www/etc/dbmpasswd"
Require valid-user
</Location>
</highlight>
<example><title>Fixed Example</title>
<highlight language="config">
-<Location /demo>
+<Location "/demo">
AuthBasicFake demo demopass
</Location>
</highlight>
<example><title>Certificate Example</title>
<highlight language="config">
-<Location /secure>
- AuthBasicFake %{SSL_CLIENT_S_DN_Email}
+<Location "/secure">
+ AuthBasicFake "%{SSL_CLIENT_S_DN_Email}"
</Location>
</highlight>
</example>
<example><title>Password Example</title>
<highlight language="config">
-<Location /secure>
- AuthBasicFake %{SSL_CLIENT_S_DN_Email} %{sha1:passphrase-%{SSL_CLIENT_S_DN_Email}}
+<Location "/secure">
+ AuthBasicFake "%{SSL_CLIENT_S_DN_Email}" "%{sha1:passphrase-%{SSL_CLIENT_S_DN_Email}}"
</Location>
</highlight>
</example>
<example><title>Exclusion Example</title>
<highlight language="config">
-<Location /public>
+<Location "/public">
AuthBasicFake off
</Location>
</highlight>
<example><title>Example:</title>
<highlight language="config">
-<Location /private/>
+<Location "/private/">
AuthType Digest
AuthName "private area"
- AuthDigestDomain /private/ http://mirror.my.dom/private2/
+ AuthDigestDomain "/private/" "http://mirror.my.dom/private2/"
AuthDigestProvider file
- AuthUserFile /web/auth/.digest_pw
+ AuthUserFile "/web/auth/.digest_pw"
Require valid-user
</Location>
</highlight>
<example><title>Basic example</title>
<highlight language="config">
AuthFormProvider file
-AuthUserFile conf/passwd
+AuthUserFile "conf/passwd"
AuthType form
AuthName realm
-AuthFormLoginRequiredLocation http://example.com/login.html
+AuthFormLoginRequiredLocation "http://example.com/login.html"
Session On
SessionCookieName session path=/
SessionCryptoPassphrase secret
<example><title>Form login handler example</title>
<highlight language="config">
-<Location /dologin.html>
+<Location "/dologin.html">
SetHandler form-login-handler
- AuthFormLoginRequiredLocation http://example.com/login.html
- AuthFormLoginSuccessLocation http://example.com/success.html
+ AuthFormLoginRequiredLocation "http://example.com/login.html"
+ AuthFormLoginSuccessLocation "http://example.com/success.html"
AuthFormProvider file
- AuthUserFile conf/passwd
+ AuthUserFile "conf/passwd"
AuthType form
AuthName realm
Session On
<example><title>Basic inline example</title>
<highlight language="config">
AuthFormProvider file
-ErrorDocument 401 /login.shtml
-AuthUserFile conf/passwd
+ErrorDocument 401 "/login.shtml"
+AuthUserFile "conf/passwd"
AuthType form
AuthName realm
-AuthFormLoginRequiredLocation http://example.com/login.html
+AuthFormLoginRequiredLocation "http://example.com/login.html"
Session On
SessionCookieName session path=/
SessionCryptoPassphrase secret
<example><title>CGI example</title>
<highlight language="config">
AuthFormProvider file
- ErrorDocument 401 /cgi-bin/login.cgi
+ ErrorDocument 401 "/cgi-bin/login.cgi"
...
</highlight>
</example>
<highlight language="config">
SetHandler form-logout-handler
AuthName realm
-AuthFormLogoutLocation http://example.com/loggedout.html
+AuthFormLogoutLocation "http://example.com/loggedout.html"
Session On
SessionCookieName session path=/
SessionCryptoPassphrase secret
<example><title>Basic session expiry example</title>
<highlight language="config">
SetHandler form-logout-handler
-AuthFormLogoutLocation http://example.com/loggedout.html
+AuthFormLogoutLocation "http://example.com/loggedout.html"
Session On
SessionMaxAge 1
SessionCookieName session path=/
<example><title>Example</title>
<highlight language="config">
-<Location /secure>
+<Location "/secure">
AuthType form
AuthName "private area"
AuthFormProvider dbm
AuthDBMType SDBM
- AuthDBMUserFile /www/etc/dbmpasswd
+ AuthDBMUserFile "/www/etc/dbmpasswd"
Require valid-user
#...
</Location>
<example><title>Example</title>
<highlight language="config">
-<Location /logout>
+<Location "/logout">
SetHandler form-logout-handler
- AuthFormLogoutLocation http://example.com/loggedout.html
+ AuthFormLogoutLocation "http://example.com/loggedout.html"
Session on
#...
</Location>
<example><title>Example</title>
<highlight language="config">
-<Directory /var/www/html/private>
+<Directory "/var/www/html/private">
AuthName "Use 'anonymous' & Email address for guest entry"
AuthType Basic
AuthBasicProvider file anon
- AuthUserFile /path/to/your/.htpasswd
+ AuthUserFile "/path/to/your/.htpasswd"
Anonymous_NoUserID off
Anonymous_MustGiveEmail on
<highlight language="config">
# Check here first
<AuthnProviderAlias file file1>
- AuthUserFile /www/conf/passwords1
+ AuthUserFile "/www/conf/passwords1"
</AuthnProviderAlias>
# Then check here
<AuthnProviderAlias file file2>
- AuthUserFile /www/conf/passwords2
+ AuthUserFile "/www/conf/passwords2"
</AuthnProviderAlias>
-<Directory /var/web/pages/secure>
+<Directory "/var/web/pages/secure">
AuthBasicProvider file1 file2
AuthType Basic
AuthLDAPURL ldap://other.ldap.host/o=dev?cn
</AuthnProviderAlias>
-Alias /secure /webpages/secure
-<Directory /webpages/secure>
+Alias "/secure" "/webpages/secure"
+<Directory "/webpages/secure">
Order deny,allow
Allow from all
<code>/www/docs/public</code> directory without authenticating:</p>
<highlight language="config">
-<Directory /www/docs>
+<Directory "/www/docs">
AuthType Basic
AuthName Documents
AuthBasicProvider file
- AuthUserFile /usr/local/apache/passwd/passwords
+ AuthUserFile "/usr/local/apache/passwd/passwords"
Require valid-user
</Directory>
-<Directory /www/docs/public>
+<Directory "/www/docs/public">
AuthType None
Require all granted
</Directory>
DBDMax 20
DBDExptime 300
-<Directory /usr/www/myhost/private>
+<Directory "/usr/www/myhost/private">
# mod_authn_core and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
<highlight language="config">
#AuthnCacheSOCache is optional. If specified, it is server-wide
AuthnCacheSOCache dbm
-<Directory /usr/www/myhost/private>
+<Directory "/usr/www/myhost/private">
AuthType Basic
AuthName "Cached Authentication Example"
AuthBasicProvider socache dbd
Example configuration:
<highlight language="config">
AuthnzFcgiDefineProvider authn FooAuthn fcgi://localhost:10102/
-<Location /protected/>
+<Location "/protected/">
AuthType Basic
AuthName "Restricted"
AuthBasicProvider FooAuthn
Example configuration:
<highlight language="config">
AuthnzFcgiDefineProvider authz FooAuthz fcgi://localhost:10103/
-<Location /protected/>
+<Location "/protected/">
AuthType ...
AuthName ...
AuthBasicProvider ...
Example configuration:
<highlight language="config">
AuthnzFcgiDefineProvider authnz FooAuthnz fcgi://localhost:10103/
-<Location /protected/>
+<Location "/protected/">
AuthType Basic
AuthName "Restricted"
AuthBasicProvider FooAuthnz
Example configuration:
<highlight language="config">
AuthnzFcgiDefineProvider authn FooAuthn fcgi://localhost:10103/
-<Location /protected/>
+<Location "/protected/">
AuthType ...
AuthName ...
AuthnzFcgiCheckAuthnProvider FooAuthn \
that gets created in the web</p>
<highlight language="config">
AuthLDAPURL "the url"
-AuthGroupFile mygroupfile
-Require group mygroupfile
+AuthGroupFile "mygroupfile"
+Require group "mygroupfile"
</highlight>
<section id="howitworks"><title>How It Works</title>
AuthLDAPURL ldap://other.ldap.host/o=dev?cn
</AuthzProviderAlias>
-Alias /secure /webpages/secure
-<Directory /webpages/secure>
+Alias "/secure" "/webpages/secure"
+<Directory "/webpages/secure">
Require all granted
AuthBasicProvider file
LDAP group <code>Temporary Employees</code>.</p>
<highlight language="config">
-<Directory /www/mydocs>
+<Directory "/www/mydocs">
<RequireAll>
<RequireAny>
Require user superadmin
<highlight language="config">
SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in
-<Directory /docroot>
+<Directory "/docroot">
Require env let_me_in
</Directory>
</highlight>
AuthType Basic
AuthName "Restricted Resource"
AuthBasicProvider file
-AuthUserFile /web/users
-AuthGroupFile /web/groups
+AuthUserFile "/web/users"
+AuthGroupFile "/web/groups"
Require group admin
</highlight>
are also in the <code>reject</code> group.</p>
<highlight language="config">
-<Directory /www/docs>
+<Directory "/www/docs">
<RequireAll>
Require group alpha beta
Require not group reject
<code>gamma</code> may access <code>/www/docs/ab/gamma</code>.</note>
<highlight language="config">
-<Directory /www/docs>
+<Directory "/www/docs">
AuthType Basic
AuthName Documents
AuthBasicProvider file
- AuthUserFile /usr/local/apache/passwd/passwords
+ AuthUserFile "/usr/local/apache/passwd/passwords"
Require group alpha
</Directory>
-<Directory /www/docs/ab>
+<Directory "/www/docs/ab">
AuthMerging Or
Require group beta
</Directory>
-<Directory /www/docs/ab/gamma>
+<Directory "/www/docs/ab/gamma">
Require group gamma
</Directory>
</highlight>
DBDMax 20
DBDExptime 300
-<Directory /usr/www/my.site/team-private/>
+<Directory "/usr/www/my.site/team-private/">
# mod_authn_core and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
# when a user fails to be authenticated or authorized,
# invite them to login; this page should provide a link
# to /team-private/login.html
- ErrorDocument 401 /login-info.html
+ ErrorDocument 401 "/login-info.html"
- <Files login.html>
+ <Files "login.html">
# don't require user to already be logged in!
AuthDBDUserPWQuery "SELECT password FROM authn WHERE user = %s"
AuthzDBDLoginToReferer On
</Files>
- <Files logout.html>
+ <Files "logout.html">
# dbd-logout action executes a statement to log user out
Require dbd-logout
AuthzDBDQuery "UPDATE authn SET login = 'false' WHERE user = %s"
<section id="examples">
<title>Example usage</title>
-<p><em>Note that using mod_authz_dbm requires you to require <code>dbm-group</code>
+<p><em>Note that using mod_authz_dbm requires you to require <code>dbm-group</code>
instead of <code>group</code>:</em>
</p>
<highlight language="config">
<Directory "/foo/bar">
- AuthType Basic
+ AuthType Basic
AuthName "Secure Area"
- AuthBasicProvider dbm
- AuthDBMUserFile site/data/users
- AuthDBMGroupFile site/data/users
- Require dbm-group admin
+ AuthBasicProvider dbm
+ AuthDBMUserFile "site/data/users"
+ AuthDBMGroupFile "site/data/users"
+ Require dbm-group admin
</Directory>
</highlight>
</section>
point to the same DBM:</p>
<highlight language="config">
-AuthDBMGroupFile /www/userbase
-AuthDBMUserFile /www/userbase
+AuthDBMGroupFile "/www/userbase"
+AuthDBMUserFile "/www/userbase"
</highlight>
<p>The key for the single DBM is the username. The value consists
were owned by <code>jones</code> instead of <code>smith</code>.</p>
<highlight language="config">
-<Directory /home/*/public_html/private>
+<Directory "/home/*/public_html/private">
AuthType Basic
AuthName MyPrivateFiles
AuthBasicProvider dbm
- AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
+ AuthDBMUserFile "/usr/local/apache2/etc/.htdbm-all"
Require file-owner
</Directory>
</highlight>
each other.</p>
<highlight language="config">
-<Directory /home/*/public_html/project-foo>
+<Directory "/home/*/public_html/project-foo">
AuthType Basic
AuthName "Project Foo Files"
AuthBasicProvider dbm
# combined user/group database
- AuthDBMUserFile /usr/local/apache2/etc/.htdbm-all
- AuthDBMGroupFile /usr/local/apache2/etc/.htdbm-all
+ AuthDBMUserFile "/usr/local/apache2/etc/.htdbm-all"
+ AuthDBMGroupFile "/usr/local/apache2/etc/.htdbm-all"
Satisfy All
Require file-group
inherited from other configuration sections. </p>
<highlight language="config">
-<Directory /var/www>
+<Directory "/var/www">
IndexIgnore *.bak .??* *~ *# HEADER* README* RCS CVS *,v *,t
</Directory>
-<Directory /var/www/backups>
+<Directory "/var/www/backups">
IndexIgnoreReset ON
IndexIgnore .??* *# HEADER* README* RCS CVS *,v *,t
</Directory>
single directory are now merged together. The result of:
<highlight language="config">
-<Directory /foo>
+<Directory "/foo">
IndexOptions HTMLTable
IndexOptions SuppressColumnsorting
</Directory>
<IfModule mod_cache.c>
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
- CacheRoot c:/cacheroot
- CacheEnable disk /
+ CacheRoot "c:/cacheroot"
+ CacheEnable disk "/"
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/
+ CacheDisable "http://security.update.server/update-list/"
</IfModule>
</highlight>
</example>
#
<IfModule mod_cache.c>
CacheLock on
- CacheLockPath /tmp/mod_cache-lock
+ CacheLockPath "/tmp/mod_cache-lock"
CacheLockMaxAge 5
</IfModule>
</highlight>
as per the following example:</p>
<highlight language="config">
-CustomLog cached-requests.log common env=cache-hit
-CustomLog uncached-requests.log common env=cache-miss
-CustomLog revalidated-requests.log common env=cache-revalidate
-CustomLog invalidated-requests.log common env=cache-invalidate
+CustomLog "cached-requests.log" common env=cache-hit
+CustomLog "uncached-requests.log" common env=cache-miss
+CustomLog "revalidated-requests.log" common env=cache-revalidate
+CustomLog "invalidated-requests.log" common env=cache-invalidate
</highlight>
<p>For module authors, a hook called <var>cache_status</var> is available,
<highlight language="config">
# Cache content (normal handler only)
CacheQuickHandler off
-<Location /foo>
+<Location "/foo">
CacheEnable disk
</Location>
# Cache regex (normal handler only)
CacheQuickHandler off
-<LocationMatch foo$>
+<LocationMatch "foo$">
CacheEnable disk
</LocationMatch>
<highlight language="config">
# Match www.example.org, and fooexample.org
-CacheEnable disk http://*example.org/
+CacheEnable disk "http://*example.org/"
# Match www.example.org, but not fooexample.org
-CacheEnable disk http://.example.org/
+CacheEnable disk "http://.example.org/"
</highlight>
<p> The <code>no-cache</code> environment variable can be set to
<example><title>Example</title>
<highlight language="config">
- CacheDisable /local_files
+ CacheDisable "/local_files"
</highlight>
</example>
<example><title>Example</title>
<highlight language="config">
-<Location /foo>
+<Location "/foo">
CacheDisable on
</Location>
</highlight>
<highlight language="config">
# Override the base URL of the cache key.
-CacheKeyBaseURL http://www.example.com/
+CacheKeyBaseURL "http://www.example.com/"
</highlight>
<note type="warning">Take care when setting this directive. If two separate virtual
<example><title>Example</title>
<highlight language="config">
-<Directory /export/home/trawick/apacheinst/htdocs/convert>
+<Directory "/export/home/trawick/apacheinst/htdocs/convert">
CharsetSourceEnc UTF-16BE
CharsetDefault ISO-8859-1
</Directory>
<example><title>Example</title>
<highlight language="config">
-<Directory /export/home/trawick/apacheinst/htdocs/convert>
+<Directory "/export/home/trawick/apacheinst/htdocs/convert">
CharsetSourceEnc UTF-16BE
CharsetDefault ISO-8859-1
</Directory>
<example><title>Configuring the filter</title>
<highlight language="config">
-<Location /data/images>
+<Location "/data/images">
SetOutputFilter DATA
</Location>
</highlight>
<example><title>Full Example</title>
<highlight language="config">
-DavLockDB /usr/local/apache2/var/DavLock
+DavLockDB "/usr/local/apache2/var/DavLock"
-<Directory /usr/local/apache2/htdocs/foo>
+<Directory "/usr/local/apache2/htdocs/foo">
Require all granted
Dav On
AuthType Basic
AuthName DAV
- AuthUserFile user.passwd
+ AuthUserFile "user.passwd"
<LimitExcept GET POST OPTIONS>
Require user admin
downloaded and manipulated with DAV.</p>
<highlight language="config">
-Alias /phparea /home/gstein/php_files
-Alias /php-source /home/gstein/php_files
-<Location /php-source>
+Alias "/phparea" "/home/gstein/php_files"
+Alias "/php-source" "/home/gstein/php_files"
+<Location "/php-source">
Dav On
ForceType text/plain
</Location>
WebDAV HTTP methods for the given container:</p>
<highlight language="config">
-<Location /foo>
+<Location "/foo">
Dav On
</Location>
</highlight>
<example><title>Example</title>
<highlight language="config">
-<Location /MSWord>
+<Location "/MSWord">
DavMinTimeout 600
</Location>
</highlight>
<example><title>Example</title>
<highlight language="config">
- DavLockDB var/DavLock
- </highlight>
+ DavLockDB "var/DavLock"
+ </highlight>
</example>
<p>The directory containing the lock database file must be
<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
>AddOutputFilter</directive>, for example:</p>
<highlight language="config">
-<Location /dav-area>
- ProxyPass http://example.com/
+<Location "/dav-area">
+ ProxyPass "http://example.com/"
SetOutputFilter INFLATE
</Location>
</highlight>
>AddInputFilter</directive>, for example:</p>
<highlight language="config">
-<Location /dav-area>
+<Location "/dav-area">
SetInputFilter DEFLATE
</Location>
</highlight>
<IfModule mod_headers.c>
# 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
# 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)$">
DeflateFilterNote ratio
LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
- CustomLog logs/deflate_log deflate
+ CustomLog "logs/deflate_log" deflate
</highlight>
</example>
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
-CustomLog logs/deflate_log deflate
+CustomLog "logs/deflate_log" deflate
</highlight>
</example>
</usage>
V.92 modem, by adding something like this:</p>
<highlight language="config">
-<Location /mysite>
- ModemStandard V.92
+<Location "/mysite">
+ ModemStandard "V.92"
</Location>
</highlight>
<p>Specify what modem standard you wish to simulate.</p>
<highlight language="config">
-<Location /mysite>
- ModemStandard V.26bis
+<Location "/mysite">
+ ModemStandard "V.26bis"
</Location>
</highlight>
to the list of resources to look for rather than replace:
</p>
<pre class="prettyprint lang-config"># Example A: Set index.html as an index page, then add index.php to that list as well.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html
DirectoryIndex index.php
</Directory>
# Example B: This is identical to example A, except it's done with a single directive.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html index.php
</Directory>
# Example C: To replace the list, you must explicitly reset it first:
# In this example, only index.php will remain as an index resource.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html
DirectoryIndex disabled
DirectoryIndex index.php
if inheritance from a parent directory is not desired.</p>
<p>In a sub-URI, such as <em>http://example.com/blog/</em> this
<em>sub-URI</em> has to be supplied as <var>local-url</var>:</p>
- <pre class="prettyprint lang-config"><Directory /web/example.com/htdocs/blog>
+ <pre class="prettyprint lang-config"><Directory "/web/example.com/htdocs/blog">
FallbackResource /blog/index.php
</Directory>
-<Directory /web/example.com/htdocs/blog/images>
+<Directory "/web/example.com/htdocs/blog/images">
FallbackResource disabled
</Directory></pre>
</p>
<highlight language="config">
# Example A: Set index.html as an index page, then add index.php to that list as well.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html
DirectoryIndex index.php
</Directory>
# Example B: This is identical to example A, except it's done with a single directive.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html index.php
</Directory>
# Example C: To replace the list, you must explicitly reset it first:
# In this example, only index.php will remain as an index resource.
-<Directory /foo>
+<Directory "/foo">
DirectoryIndex index.html
DirectoryIndex disabled
DirectoryIndex index.php
<highlight language="config">
# see security warning below!
-<Location /some/path>
+<Location "/some/path">
DirectorySlash Off
SetHandler some-handler
</Location>
<p>In a sub-URI, such as <em>http://example.com/blog/</em> this
<em>sub-URI</em> has to be supplied as <var>local-url</var>:</p>
<highlight language="config">
-<Directory /web/example.com/htdocs/blog>
+<Directory "/web/example.com/htdocs/blog">
FallbackResource /blog/index.php
</Directory>
-<Directory /web/example.com/htdocs/blog/images>
+<Directory "/web/example.com/htdocs/blog/images">
FallbackResource disabled
</Directory>
</highlight>
<p>To activate the example_hooks module, include a block similar to
the following in your <code>httpd.conf</code> file:</p>
<highlight language="config">
-<Location /example-hooks-info>
+<Location "/example-hooks-info">
SetHandler example-hooks-handler
</Location>
</highlight>
href="core.html#accessfilename"><code>.htaccess</code></a> file
and then request the file "test.example" from that location:</p>
<highlight language="config">
- AddHandler example-hooks-handler .example
+ AddHandler example-hooks-handler ".example"
</highlight>
<p>After reloading/restarting your server, you should be able
# mod_ext_filter directive to define the external filter
ExtFilterDefine gzip mode=output cmd=/bin/gzip
-<Location /gzipped>
+<Location "/gzipped">
# core directive to cause the gzip filter to be
# run on output
ExtFilterDefine slowdown mode=output cmd=/bin/cat \
preservescontentlength
-<Location />
+<Location "/">
# core directive to cause the slowdown filter to
# be run several times on output
#
ExtFilterDefine fixtext mode=output intype=text/html \
cmd="/bin/sed s/verdana/arial/g"
-<Location />
+<Location "/">
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext
cmd="/bin/tracefilter.pl /tmp/traceafter" \
EnableEnv=trace_this_client ftype=21
-<Directory /usr/local/docs>
+<Directory "/usr/local/docs">
SetEnvIf Remote_Addr 192.168.1.31 trace_this_client
SetOutputFilter tracebefore;deflate;traceafter
</Directory>
FilterProvider repack jpeg_pack "%{CONTENT_TYPE} = 'image/jpeg'"
FilterProvider repack gif_pack "%{CONTENT_TYPE} = 'image/gif'"
FilterProvider repack png_pack "%{CONTENT_TYPE} = 'image/png'"
-<Location /image-filter>
+<Location "/image-filter">
FilterChain unpack downsample repack
</Location>
</highlight>
filter.</p>
<highlight language="config">
-<Location /cgi-bin/>
+<Location "/cgi-bin/">
Options Includes
AddOutputFilterByType INCLUDES;DEFLATE text/html
</Location>
<code>httpd.conf</code> file.</p>
<highlight language="config">
-<Location /server-info>
+<Location "/server-info">
SetHandler server-info
</Location>
</highlight>
information:</p>
<highlight language="config">
-<Location /server-info>
+<Location "/server-info">
SetHandler server-info
Require host example.com
</Location>
<example><title>Access control</title>
<highlight language="config">
-<Location /server-info>
+<Location "/server-info">
SetHandler server-info
Order allow,deny
# Allow access from server itself
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600
-<Location /ldap-status>
+<Location "/ldap-status">
SetHandler ldap-status
Require host yourdomain.example.com
AuthType Basic
AuthName "LDAP Protected"
AuthBasicProvider ldap
- AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one
+ AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=com?uid?one"
Require valid-user
</Location>
</highlight>
<module>mod_ldap</module> cache information:</p>
<highlight language="config">
-<Location /server/cache-info>
+<Location "/server/cache-info">
SetHandler ldap-status
</Location>
</highlight>
# mod_ldap and mod_authnz_ldap be loaded. Change the
# "yourdomain.example.com" to match your domain.
-LDAPTrustedGlobalCert CA_DER /certs/certfile.der
+LDAPTrustedGlobalCert CA_DER "/certs/certfile.der"
-<Location /ldap-status>
+<Location "/ldap-status">
SetHandler ldap-status
Require host yourdomain.example.com
AuthType Basic
AuthName "LDAP Protected"
AuthBasicProvider ldap
- AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
+ AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one"
Require valid-user
</Location>
</highlight>
# mod_ldap and mod_authnz_ldap be loaded. Change the
# "yourdomain.example.com" to match your domain.
-LDAPTrustedGlobalCert CA_DER /certs/certfile.der
+LDAPTrustedGlobalCert CA_DER "/certs/certfile.der:
-<Location /ldap-status>
+<Location "/ldap-status">
SetHandler ldap-status
Require host yourdomain.example.com
AuthType Basic
AuthName "LDAP Protected"
AuthBasicProvider ldap
- AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one TLS
+ AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=com?uid?one" TLS
Require valid-user
</Location>
</highlight>
<highlight language="config">
# Specify a Netscape CA certificate file
-LDAPTrustedGlobalCert CA_CERT7_DB /certs/cert7.db
+LDAPTrustedGlobalCert CA_CERT7_DB "/certs/cert7.db"
# Specify an optional key3.db file for client certificate support
-LDAPTrustedGlobalCert CERT_KEY3_DB /certs/key3.db
+LDAPTrustedGlobalCert CERT_KEY3_DB "/certs/key3.db"
# Specify the secmod file if required
-LDAPTrustedGlobalCert CA_SECMOD /certs/secmod
-<Location /ldap-status>
+LDAPTrustedGlobalCert CA_SECMOD "/certs/secmod"
+<Location "/ldap-status">
SetHandler ldap-status
Require host yourdomain.example.com
AuthName "LDAP Protected"
AuthBasicProvider ldap
LDAPTrustedClientCert CERT_NICKNAME <nickname> [password]
- AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
+ AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one"
Require valid-user
</Location>
</highlight>
<highlight language="config">
# Specify two CA certificate files
-LDAPTrustedGlobalCert CA_DER /certs/cacert1.der
-LDAPTrustedGlobalCert CA_BASE64 /certs/cacert2.pem
+LDAPTrustedGlobalCert CA_DER "/certs/cacert1.der"
+LDAPTrustedGlobalCert CA_BASE64 "/certs/cacert2.pem"
# Specify a client certificate file and key
-LDAPTrustedGlobalCert CERT_BASE64 /certs/cert1.pem
-LDAPTrustedGlobalCert KEY_BASE64 /certs/key1.pem [password]
+LDAPTrustedGlobalCert CERT_BASE64 "/certs/cert1.pem"
+LDAPTrustedGlobalCert KEY_BASE64 "/certs/key1.pem" [password]
# Do not use this directive, as it will throw an error
-#LDAPTrustedClientCert CERT_BASE64 /certs/cert1.pem
+#LDAPTrustedClientCert CERT_BASE64 "/certs/cert1.pem"
</highlight>
</section>
<highlight language="config">
# Specify two CA certificate files
-LDAPTrustedGlobalCert CA_DER /certs/cacert1.der
-LDAPTrustedGlobalCert CA_BASE64 /certs/cacert2.pem
-<Location /ldap-status>
+LDAPTrustedGlobalCert CA_DER "/certs/cacert1.der"
+LDAPTrustedGlobalCert CA_BASE64 "/certs/cacert2.pem"
+<Location "/ldap-status">
SetHandler ldap-status
Require host yourdomain.example.com
- LDAPTrustedClientCert CERT_BASE64 /certs/cert1.pem
- LDAPTrustedClientCert KEY_BASE64 /certs/key1.pem
+ LDAPTrustedClientCert CERT_BASE64 "/certs/cert1.pem"
+ LDAPTrustedClientCert KEY_BASE64 "/certs/key1.pem"
# CA certs respecified due to per-directory client certs
- LDAPTrustedClientCert CA_DER /certs/cacert1.der
- LDAPTrustedClientCert CA_BASE64 /certs/cacert2.pem
+ LDAPTrustedClientCert CA_DER "/certs/cacert1.der"
+ LDAPTrustedClientCert CA_BASE64 "/certs/cacert2.pem"
Satisfy any
AuthType Basic
AuthName "LDAP Protected"
AuthBasicProvider ldap
- AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one
+ AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one"
Require valid-user
</Location>
</highlight>
<highlight language="config">
# CustomLog with format nickname
LogFormat "%h %l %u %t \"%r\" %>s %b" common
-CustomLog logs/access_log common
+CustomLog "logs/access_log" common
# CustomLog with explicit format string
-CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b"
+CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b"
</highlight>
<p>The third argument is optional and controls whether or
<highlight language="config">
SetEnvIf Request_URI \.gif$ gif-image
-CustomLog gif-requests.log common env=gif-image
-CustomLog nongif-requests.log common env=!gif-image
+CustomLog "gif-requests.log" common env=gif-image
+CustomLog "nongif-requests.log" common env=!gif-image
</highlight>
<p>Or, to reproduce the behavior of the old RefererIgnore
<highlight language="config">
SetEnvIf Referer example\.com localreferer
-CustomLog referer.log referer env=!localreferer
+CustomLog "referer.log" referer env=!localreferer
</highlight>
</usage>
</directivesynopsis>
Log message after request to /foo/* is processed:
<highlight language="config">
-<Location /foo/>
+<Location "/foo/">
LogMessage "/foo/ has been requested"
</Location>
</highlight>
<li>
Log message if request to /foo/* is processed in a sub-request:
<highlight language="config">
-<Location /foo/>
+<Location "/foo/">
LogMessage "subrequest to /foo/" hook=type_checker expr=%{IS_SUBREQ}
</Location>
</highlight>
Log the value of the "X-Foo" request environment variable in each
stage of the request:
<highlight language="config">
-<Location />
+<Location "/">
LogMessage "%{reqenv:X-Foo}" hook=all
</Location>
</highlight>
<directive module="mod_mime">AddHandler</directive> directive:</p>
<highlight language="config">
-<Files *.lua>
+<Files "*.lua">
SetHandler lua-script
</Files>
</highlight>
<code>foo</code> and configures it for URL <code>/</code>:</p>
<highlight language="config">
LuaAuthzProvider foo authz_provider.lua authz_check_foo
-<Location />
+<Location "/">
Require foo 10.1.2.3 john_doe
</Location>
</highlight>
issues.</p>
<example><title>Examples:</title>
<highlight language="config">
- LuaMapHandler /(\w+)/(\w+) /scripts/$1.lua handle_$2
+ LuaMapHandler "/(\w+)/(\w+)" "/scripts/$1.lua" "handle_$2"
</highlight>
</example>
<p>This would match uri's such as /photos/show?id=9
loading that file.</p>
<highlight language="config">
- LuaMapHandler /bingo /scripts/wombat.lua
+ LuaMapHandler "/bingo" "/scripts/wombat.lua"
</highlight>
<p>This would invoke the "handle" function, which
is the default if no specific function name is
<example><title>Examples:</title>
<highlight language="config">
-LuaPackagePath /scripts/lib/?.lua
-LuaPackagePath /scripts/lib/?/init.lua
+LuaPackagePath "/scripts/lib/?.lua"
+LuaPackagePath "/scripts/lib/?/init.lua"
</highlight>
</example>
</usage>
<highlight language="config">
# httpd.conf
-LuaHookTranslateName /scripts/conf/hooks.lua silly_mapper
+LuaHookTranslateName "/scripts/conf/hooks.lua" silly_mapper
</highlight>
<highlight language="lua">
</p>
<p>Example:</p>
<highlight language="config">
-LuaHookLog /path/to/script.lua logger
+LuaHookLog "/path/to/script.lua" logger
</highlight>
<highlight language="lua">
-- /path/to/script.lua --
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">
- LuaHookMapToStorage /path/to/lua/script.lua check_cache
+ LuaHookMapToStorage "/path/to/lua/script.lua" check_cache
</highlight>
<highlight language="lua">
require"apache2"
be used to modify the type and handler based on input:
</p>
<highlight language="config">
- LuaHookTypeChecker /path/to/lua/script.lua type_checker
+ LuaHookTypeChecker "/path/to/lua/script.lua" type_checker
</highlight>
<highlight language="lua">
function type_checker(r)
with the <directive module="mod_authz_core">Require</directive> directive:</p>
<highlight language="config">
-LuaRoot /usr/local/apache2/lua
+LuaRoot "/usr/local/apache2/lua"
LuaAuthzProvider foo authz.lua authz_check_foo
-<Location />
+<Location "/">
Require foo johndoe
</Location>
</highlight>
</p>
<highlight language="config">
-LuaInputFilter myInputFilter /www/filter.lua input_filter
-<Files *.lua>
+LuaInputFilter myInputFilter "/www/filter.lua" input_filter
+<Files "*.lua">
SetInputFilter myInputFilter
</Files>
</highlight>
</p>
<highlight language="config">
-LuaOutputFilter myOutputFilter /www/filter.lua output_filter
-<Files *.lua>
+LuaOutputFilter myOutputFilter "/www/filter.lua" output_filter
+<Files "*.lua">
SetOutputFilter myOutputFilter
</Files>
</highlight>
ServerName $domain
ServerAlias www.$domain
- DocumentRoot /var/www/vhosts/$name
- ErrorLog /var/log/httpd/$name.error_log
- CustomLog /var/log/httpd/$name.access_log combined
+ DocumentRoot "/var/www/vhosts/$name"
+ ErrorLog "/var/log/httpd/$name.error_log"
+ CustomLog "/var/log/httpd/$name.access_log" combined
</VirtualHost>
</Macro>
</highlight>
<highlight language="config">
<Macro DocRoot ${docroot}>
- DocumentRoot /var/www/${docroot}/htdocs
+ DocumentRoot "/var/www/${docroot}/htdocs"
</Macro>
</highlight>
<VirtualHost *:$port>
ServerName $host
- DocumentRoot $dir
+ DocumentRoot "$dir"
# Public document root
- <Directory $dir>
+ <Directory "$dir">
Require all granted
</Directory>
# limit access to intranet subdir.
- <Directory $dir/intranet>
+ <Directory "$dir/intranet">
Require ip 10.0.0.0/8
</Directory>
</VirtualHost>
<highlight language="config">
<Macro DirGroup $dir $group>
- <Directory $dir>
+ <Directory "$dir">
Require group $group
</Directory>
</Macro>
<example><title>Configure handler based on final extension only</title>
<highlight language="config">
-<FilesMatch \.cgi$>
+<FilesMatch "\.cgi$">
SetHandler cgi-script
</FilesMatch>
</highlight>
<highlight language="config">
# Effective filter "DEFLATE"
AddOutputFilter DEFLATE shtml
-<Location /foo>
+<Location "/foo">
# Effective filter "INCLUDES", replacing "DEFLATE"
AddOutputFilter INCLUDES shtml
</Location>
-<Location /bar>
+<Location "/bar">
# Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"
AddOutputFilter INCLUDES;DEFLATE shtml
</Location>
-<Location /bar/baz>
+<Location "/bar/baz">
# Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"
AddOutputFilter BUFFER shtml
</Location>
-<Location /bar/baz/buz>
+<Location "/bar/baz/buz">
# No effective filter, replacing "BUFFER"
RemoveOutputFilter shtml
</Location>
<highlight language="config">
AddEncoding x-gzip .gz
AddType text/plain .asc
-<Files *.gz.asc>
+<Files "*.gz.asc">
RemoveEncoding .gz
</Files>
</highlight>
<example><title>Reverse Proxy</title>
<highlight language="config">
-ProxyPass /foo http://foo.example.com/bar
-ProxyPassReverse /foo http://foo.example.com/bar
+ProxyPass "/foo" "http://foo.example.com/bar"
+ProxyPassReverse "/foo" "http://foo.example.com/bar"
</highlight>
</example>
ProxyRequests On
ProxyVia On
-<Proxy *>
+<Proxy "*">
Require host internal.example.com
</Proxy>
</highlight>
<example><title>Reverse Proxy PHP scripts</title>
<highlight language="config">
-<FilesMatch \.php$>
+<FilesMatch "\.php$">
# Unix sockets require 2.4.7 or later
SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
for a reverse proxy:</p>
<highlight language="config">
- ProxyPass /example http://backend.example.com connectiontimeout=5 timeout=30
+ ProxyPass "/example" "http://backend.example.com" connectiontimeout=5 timeout=30
</highlight>
<p>This will create a worker associated with the origin server URL
via the <directive module="mod_proxy">ProxySet</directive> directive:</p>
<highlight language="config">
- ProxySet http://backend.example.com connectiontimeout=5 timeout=30
+ ProxySet "http://backend.example.com" connectiontimeout=5 timeout=30
</highlight>
<p>or alternatively using <directive module="mod_proxy">Proxy</directive>
and <directive module="mod_proxy">ProxySet</directive>:</p>
<highlight language="config">
-<Proxy http://backend.example.com>
+<Proxy "http://backend.example.com">
ProxySet connectiontimeout=5 timeout=30
</Proxy>
</highlight>
origin server including any path components given:</p>
<highlight language="config">
-ProxyPass /examples http://backend.example.com/examples
-ProxyPass /docs http://backend.example.com/docs
+ProxyPass "/examples" "http://backend.example.com/examples"
+ProxyPass "/docs" "http://backend.example.com/docs"
</highlight>
<p>This example defines two different workers, each using a separate
worker defined later in the configuration file. In the following example</p>
<highlight language="config">
-ProxyPass /apps http://backend.example.com/ timeout=60
-ProxyPass /examples http://backend.example.com/examples timeout=10
+ProxyPass "/apps" "http://backend.example.com/" timeout=60
+ProxyPass "/examples" "http://backend.example.com/examples" timeout=10
</highlight>
<p>the second worker isn't actually created. Instead the first
the following example:</p>
<highlight language="config">
-<Proxy *>
+<Proxy "*">
Require ip 192.168.0
</Proxy>
</highlight>
<code>proxy-nokeepalive</code> notes.</p>
<highlight language="config">
-<Location /buggyappserver/>
- ProxyPass http://buggyappserver:7001/foo/
+<Location "/buggyappserver/">
+ ProxyPass "http://buggyappserver:7001/foo/"
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>
server:</p>
<highlight language="config">
-<Proxy *>
+<Proxy "*">
Require host yournetwork.example.com
</Proxy>
</highlight>
filter when they are sent through the proxy server:</p>
<highlight language="config">
-<Proxy http://example.com/foo/*>
+<Proxy "http://example.com/foo/*">
SetOutputFilter INCLUDES
</Proxy>
</highlight>
<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
+ <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 <directive type="section" module="core"
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<ProxyMatch ^http://(?<sitename>[^/]+)>
+<ProxyMatch "^http://(?<sitename>[^/]+)">
Require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</ProxyMatch>
</highlight>
<example><title>Example</title>
<highlight language="config">
-ProxyRemote http://goodguys.example.com/ http://mirrorguys.example.com:8000
-ProxyRemote * http://cleverproxy.localdomain
-ProxyRemote ftp http://ftpproxy.mydomain:8080
+ProxyRemote "http://goodguys.example.com/" "http://mirrorguys.example.com:8000"
+ProxyRemote "*" "http://cleverproxy.localdomain"
+ProxyRemote "ftp" "http://ftpproxy.mydomain:8080"
</highlight>
</example>
<example>
<highlight language="config">
-<Proxy balancer://hotcluster>
- BalancerMember http://www2.example.com:8080 loadfactor=1
- BalancerMember http://www3.example.com:8080 loadfactor=2
+<Proxy "balancer://hotcluster">
+ BalancerMember "http://www2.example.com:8080" loadfactor=1
+ BalancerMember "http://www3.example.com:8080" loadfactor=2
ProxySet lbmethod=bytraffic
</Proxy>
</highlight>
</example>
<highlight language="config">
-<Proxy http://backend>
+<Proxy "http://backend">
ProxySet keepalive=On
</Proxy>
</highlight>
<highlight language="config">
- ProxySet balancer://foo lbmethod=bytraffic timeout=15
+ ProxySet "balancer://foo" lbmethod=bytraffic timeout=15
</highlight>
<highlight language="config">
- ProxySet ajp://backend:7001 timeout=15
+ ProxySet "ajp://backend:7001" timeout=15
</highlight>
<note type="warning"><title>Warning</title>
then</p>
<highlight language="config">
-<Location /mirror/foo/>
- ProxyPass http://backend.example.com/
+<Location "/mirror/foo/">
+ ProxyPass "http://backend.example.com/"
</Location>
</highlight>
<a href="mod_proxy_balancer.html#balancer_manager">Balancer Manager</a> interface:</p>
<highlight language="config">
- ProxyPass /mirror/foo/ http://backend.example.com/
+ ProxyPass "/mirror/foo/" "http://backend.example.com/"
</highlight>
<note type="warning">
to reverse-proxy a subdirectory, <em>e.g.</em></p>
<highlight language="config">
-<Location /mirror/foo/>
- ProxyPass http://backend.example.com/
+<Location "/mirror/foo/">
+ ProxyPass "http://backend.example.com/"
</Location>
-<Location /mirror/foo/i>
- ProxyPass !
+<Location "/mirror/foo/i">
+ ProxyPass "!"
</Location>
</highlight>
<highlight language="config">
-ProxyPass /mirror/foo/i !
-ProxyPass /mirror/foo http://backend.example.com
+ProxyPass "/mirror/foo/i" "!"
+ProxyPass "/mirror/foo" "http://backend.example.com"
</highlight>
<p>will proxy all requests to <code>/mirror/foo</code> to
<example><title>Example</title>
<highlight language="config">
- ProxyPass /example http://backend.example.com max=20 ttl=120 retry=300
+ ProxyPass "/example" "http://backend.example.com" max=20 ttl=120 retry=300
</highlight>
</example>
</table>
<p>A sample balancer setup</p>
<highlight language="config">
-ProxyPass /special-area http://special.example.com smax=5 max=10
-ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On
-<Proxy balancer://mycluster>
- BalancerMember ajp://1.2.3.4:8009
- BalancerMember ajp://1.2.3.5:8009 loadfactor=20
+ProxyPass "/special-area" "http://special.example.com" smax=5 max=10
+ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofailover=On
+<Proxy "balancer://mycluster">
+ BalancerMember "ajp://1.2.3.4:8009"
+ BalancerMember "ajp://1.2.3.5:8009" loadfactor=20
# Less powerful server, don't send as many requests there,
- BalancerMember ajp://1.2.3.6:8009 loadfactor=5
+ BalancerMember "ajp://1.2.3.6:8009" loadfactor=5
</Proxy>
</highlight>
<p>Setting up a hot-standby, that will only be used if no other
members are available</p>
<highlight language="config">
-ProxyPass / balancer://hotcluster/
-<Proxy balancer://hotcluster>
- BalancerMember ajp://1.2.3.4:8009 loadfactor=1
- BalancerMember ajp://1.2.3.5:8009 loadfactor=2
+ProxyPass "/" "balancer://hotcluster/"
+<Proxy "balancer://hotcluster">
+ BalancerMember "ajp://1.2.3.4:8009" loadfactor=1
+ BalancerMember "ajp://1.2.3.5:8009" loadfactor=2
# The server below is on hot standby
- BalancerMember ajp://1.2.3.6:8009 status=+H
+ BalancerMember "ajp://1.2.3.6:8009" status=+H
ProxySet lbmethod=bytraffic
</Proxy>
</highlight>
<highlight language="config">
RewriteEngine On
-RewriteCond %{HTTPS} =off
-RewriteRule . - [E=protocol:http]
-RewriteCond %{HTTPS} =on
-RewriteRule . - [E=protocol:https]
+RewriteCond "%{HTTPS}" =off
+RewriteRule "." "-" [E=protocol:http]
+RewriteCond "%{HTTPS}" =on
+RewriteRule "." "-" [E=protocol:https]
-RewriteRule ^/mirror/foo/(.*) %{ENV:protocol}://backend.example.com/$1 [P]
-ProxyPassReverse /mirror/foo/ http://backend.example.com/
-ProxyPassReverse /mirror/foo/ https://backend.example.com/
+RewriteRule "^/mirror/foo/(.*)" "%{ENV:protocol}://backend.example.com/$1" [P]
+ProxyPassReverse "/mirror/foo/" "http://backend.example.com/"
+ProxyPassReverse "/mirror/foo/" "https://backend.example.com/"
</highlight>
</usage>
</directivesynopsis>
then</p>
<highlight language="config">
- ProxyPassMatch ^/(.*\.gif)$ http://backend.example.com/$1
+ ProxyPassMatch "^/(.*\.gif)$" "http://backend.example.com/$1"
</highlight>
<p>will cause a local request for
substitutions (as well as after). This limits the matches you can use.
For instance, if we had used</p>
<highlight language="config">
- ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com:8000$1
+ ProxyPassMatch "^(/.*\.gif)$" "http://backend.example.com:8000$1"
</highlight>
<p>in our previous example, it would fail with a syntax error
at server startup. This is a bug (PR 46665 in the ASF bugzilla),
and the workaround is to reformulate the match:</p>
<highlight language="config">
- ProxyPassMatch ^/(.*\.gif)$ http://backend.example.com:8000/$1
+ ProxyPassMatch "^/(.*\.gif)$" "http://backend.example.com:8000/$1"
</highlight>
</note>
<p>The <code>!</code> directive is useful in situations where you don't want
<code>http://example.com/</code>; then</p>
<highlight language="config">
-ProxyPass /mirror/foo/ http://backend.example.com/
-ProxyPassReverse /mirror/foo/ http://backend.example.com/
-ProxyPassReverseCookieDomain backend.example.com public.example.com
-ProxyPassReverseCookiePath / /mirror/foo/
+ProxyPass "/mirror/foo/" "http://backend.example.com/"
+ProxyPassReverse "/mirror/foo/" "http://backend.example.com/"
+ProxyPassReverseCookieDomain "backend.example.com" "public.example.com"
+ProxyPassReverseCookiePath "/" "/mirror/foo/"
</highlight>
<p>will not only cause a local request for the
<directive module="mod_proxy">ProxyPassReverse</directive>, the directive:
</p>
<highlight language="config">
- ProxyPassReverseCookiePath / /mirror/foo/
+ ProxyPassReverseCookiePath "/" "/mirror/foo/"
</highlight>
<p>
will rewrite a cookie with backend path <code>/</code> (or
<example><title>Example</title>
<highlight language="config">
- ProxyBlock news.example.com auctions.example.com friends.example.com
+ ProxyBlock "news.example.com" "auctions.example.com" "friends.example.com"
</highlight>
</example>
<p>Note also that</p>
<highlight language="config">
- ProxyBlock *
+ ProxyBlock "*"
</highlight>
<p>blocks connections to all sites.</p>
<example><title>Example</title>
<highlight language="config">
-ProxyRemote * http://firewall.example.com:81
-NoProxy .example.com 192.168.112.0/21
+ProxyRemote "*" "http://firewall.example.com:81"
+NoProxy ".example.com" "192.168.112.0/21"
</highlight>
</example>
<example><title>Example</title>
<highlight language="config">
- ProxyRemote * http://firewall.example.com:81<br />
- NoProxy .example.com 192.168.112.0/21<br />
- ProxyDomain .example.com
+ ProxyRemote "*" "http://firewall.example.com:81"<br />
+ NoProxy ".example.com" "192.168.112.0/21"<br />
+ ProxyDomain ".example.com"
</highlight>
</example>
</usage>
<example><title>Simple Reverse Proxy</title>
<highlight language="config">
- ProxyPass /app ajp://backend.example.com:8009/app
+ ProxyPass "/app" "ajp://backend.example.com:8009/app"
</highlight>
</example>
<p>Balancers may also be used:</p>
<example><title>Balancer Reverse Proxy</title>
<highlight language="config">
-<Proxy balancer://cluster>
- BalancerMember ajp://app1.example.com:8009 loadfactor=1
- BalancerMember ajp://app2.example.com:8009 loadfactor=2
+<Proxy "balancer://cluster">
+ BalancerMember "ajp://app1.example.com:8009" loadfactor=1
+ BalancerMember "ajp://app2.example.com:8009" loadfactor=2
ProxySet lbmethod=bytraffic
</Proxy>
-ProxyPass /app balancer://cluster/app
+ProxyPass "/app" "balancer://cluster/app"
</highlight>
</example>
example:</p>
<example><title>Rewriting Proxied Path</title>
<highlight language="config">
-ProxyPass /apps/foo ajp://backend.example.com:8009/foo
-ProxyPassReverse /apps/foo http://www.example.com/foo
+ProxyPass "/apps/foo" "ajp://backend.example.com:8009/foo"
+ProxyPassReverse "/apps/foo" "http://www.example.com/foo"
</highlight>
</example>
<p>However, it is usually better to deploy the application on the backend
</p>
<highlight language="config">
-<Proxy balancer://mycluster>
- BalancerMember http://192.168.1.50:80
- BalancerMember http://192.168.1.51:80
+<Proxy "balancer://mycluster">
+ BalancerMember "http://192.168.1.50:80"
+ BalancerMember "http://192.168.1.51:80"
</Proxy>
-ProxyPass /test balancer://mycluster
-ProxyPassReverse /test balancer://mycluster
+ProxyPass "/test" "balancer://mycluster"
+ProxyPassReverse "/test" "balancer://mycluster"
</highlight>
<p>Another example of how to provide load balancing with stickyness
<highlight language="config">
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
-<Proxy balancer://mycluster>
- BalancerMember http://192.168.1.50:80 route=1
- BalancerMember http://192.168.1.51:80 route=2
+<Proxy "balancer://mycluster">
+ BalancerMember "http://192.168.1.50:80" route=1
+ BalancerMember "http://192.168.1.51:80" route=2
ProxySet stickysession=ROUTEID
</Proxy>
-ProxyPass /test balancer://mycluster
-ProxyPassReverse /test balancer://mycluster
+ProxyPass "/test" "balancer://mycluster"
+ProxyPassReverse "/test" "balancer://mycluster"
</highlight>
</section>
domain add this code to your <code>httpd.conf</code>
configuration file</p>
<highlight language="config">
-<Location /balancer-manager>
+<Location "/balancer-manager">
SetHandler balancer-manager
Require host example.com
</Location>
configuring the name of the cookie and the name of the URL parameter
separated by a vertical bar (<code>|</code>) as in the following example:</p>
<highlight language="config">
-ProxyPass /test balancer://mycluster stickysession=JSESSIONID|jsessionid scolonpathdelim=On
-<Proxy balancer://mycluster>
- BalancerMember http://192.168.1.50:80 route=node1
- BalancerMember http://192.168.1.51:80 route=node2
+ProxyPass "/test" "balancer://mycluster" stickysession=JSESSIONID|jsessionid scolonpathdelim=On
+<Proxy "balancer://mycluster">
+ BalancerMember "http://192.168.1.50:80" route=node1
+ BalancerMember "http://192.168.1.51:80" route=node2
</Proxy>
</highlight>
<p>If the cookie and the request parameter both provide routing information
<highlight language="config">
<VirtualHost *:80>
ServerName front.end.server
- ProxyPass / back.end.server:port
- ProxyPassReverse / back.end.server:port
+ ProxyPass "/" "back.end.server:port"
+ ProxyPassReverse "/" "back.end.server:port"
</VirtualHost>
</highlight>
That is, the entire URL is appended to the mapped backend
<example><title>Single application instance</title>
<highlight language="config">
- ProxyPass /myapp/ fcgi://localhost:4000/
+ ProxyPass "/myapp/" "fcgi://localhost:4000/"
</highlight>
</example>
<example><title>Single application instance, connection reuse (2.4.11 and later)</title>
<highlight language="config">
- ProxyPass /myapp/ fcgi://localhost:4000/ enablereuse=on
+ ProxyPass "/myapp/" "fcgi://localhost:4000/" enablereuse=on
</highlight>
</example>
PHP-FPM is listening. Connection pooling is enabled.</p>
<example><title>PHP-FPM</title>
<highlight language="config">
- ProxyPassMatch ^/myapp/.*\.php(/.*)?$ fcgi://localhost:9000/var/www/ enablereuse=on
+ ProxyPassMatch "^/myapp/.*\.php(/.*)?$" "fcgi://localhost:9000/var/www/" enablereuse=on
</highlight>
</example>
<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>
<example><title>Balanced gateway to multiple application instances</title>
<highlight language="config">
-ProxyPass /myapp/ balancer://myappcluster/
-<Proxy balancer://myappcluster/>
- BalancerMember fcgi://localhost:4000
- BalancerMember fcgi://localhost:4001
+ProxyPass "/myapp/" "balancer://myappcluster/"
+<Proxy "balancer://myappcluster/">
+ BalancerMember "fcgi://localhost:4000"
+ BalancerMember "fcgi://localhost:4001"
</Proxy>
</highlight>
</example>
</p>
<example><title>Proxy via Handler</title>
<highlight language="config">
-<FilesMatch \.php$>
+<FilesMatch "\.php$">
# Note: The only part that varies is /path/to/app.sock
SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
# 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>
+ <Proxy "fcgi://localhost/" enablereuse=on max=10>
</Proxy>
<FilesMatch ...>
<example><title>Balanced gateway</title>
<highlight language="config">
-ProxyPass /scgi-bin/ balancer://somecluster/
-<Proxy balancer://somecluster>
- BalancerMember scgi://localhost:4000
- BalancerMember scgi://localhost:4001
+ProxyPass "/scgi-bin/" "balancer://somecluster/"
+<Proxy "balancer://somecluster">
+ BalancerMember "scgi://localhost:4000"
+ BalancerMember "scgi://localhost:4001"
</Proxy>
</highlight>
</example>
<example><title>Proxying requests to websockets server</title>
<highlight language="config">
-ProxyPass /ws2/ ws://echo.websocket.org/
-ProxyPass /wss2/ wss://echo.websocket.org/
+ProxyPass "/ws2/" "ws://echo.websocket.org/"
+ProxyPass "/wss2/" "wss://echo.websocket.org/"
</highlight>
</example>
<example><title>Example Configuration</title>
<highlight language="config">
-<Location /downloads>
+<Location "/downloads">
SetOutputFilter RATE_LIMIT
SetEnv rate-limit 400
</Location>
body. This request requires a Content-Encoding request header containing
"gzip" for the filter to return compressed data.
<highlight language="config">
-<Location /compress>
+<Location "/compress">
SetHandler reflector
SetOutputFilter DEFLATE
</Location>
<dd>Pass the request body through an image downsampling filter, and reflect
the results to the caller.
<highlight language="config">
-<Location /downsample>
+<Location "/downsample">
SetHandler reflector
SetOutputFilter DOWNSAMPLE
</Location>
<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 following combinations for <em>MapType</em> and
misconfiguration would normally cause the server to look for an "opt"
directory under the document root.</p>
<highlight language="config">
-DocumentRoot /var/www/example.com
-AliasMatch ^/myapp /opt/myapp-1.2.3
-<Directory /opt/myapp-1.2.3>
+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
+ RewriteRule "^index\.html$" "welcome.html"
</Directory>
</highlight>
<highlight language="config">
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
- RewriteRule ^/images - [F]
+ 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
SessionCryptoPassphrase secret
SessionCookieName session path=/
AuthFormProvider file
-AuthUserFile conf/passwd
+AuthUserFile "conf/passwd"
AuthType form
AuthName realm
#...
directory names.</li>
<li>spelling corrections apply strictly to existing files, so
- a request for the <code><Location /status></code> may
+ a request for the <code><Location "/status"></code> may
get incorrectly treated as the negotiated file
"<code>/stats.html</code>".</li>
</ul>
href="../ssl/ssl_compat.html">Compatibility</a> chapter.</p>
<example><title>Example</title>
<highlight language="config">
-CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
+CustomLog "logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</highlight>
</example>
</section>
</ul>
<example><title>Example</title>
<highlight language="config">
-SSLPassPhraseDialog exec:/usr/local/apache/sbin/pp-filter
+SSLPassPhraseDialog "exec:/usr/local/apache/sbin/pp-filter"
</highlight>
</example>
</usage>
<example><title>Example</title>
<highlight language="config">
SSLRandomSeed startup builtin
-SSLRandomSeed startup file:/dev/random
-SSLRandomSeed startup file:/dev/urandom 1024
-SSLRandomSeed startup exec:/usr/local/bin/truerand 16
+SSLRandomSeed startup "file:/dev/random"
+SSLRandomSeed startup "file:/dev/urandom" 1024
+SSLRandomSeed startup "exec:/usr/local/bin/truerand" 16
SSLRandomSeed connect builtin
-SSLRandomSeed connect file:/dev/random
-SSLRandomSeed connect file:/dev/urandom 1024
+SSLRandomSeed connect "file:/dev/random"
+SSLRandomSeed connect "file:/dev/urandom" 1024
</highlight>
</example>
</usage>
<example><title>Examples</title>
<highlight language="config">
-SSLSessionCache dbm:/usr/local/apache/logs/ssl_gcache_data
-SSLSessionCache shmcb:/usr/local/apache/logs/ssl_gcache_data(512000)
+SSLSessionCache "dbm:/usr/local/apache/logs/ssl_gcache_data"
+SSLSessionCache "shmcb:/usr/local/apache/logs/ssl_gcache_data(512000)"
</highlight>
</example>
<example><title>Example</title>
<highlight language="config">
-SSLCertificateFile /usr/local/apache2/conf/ssl.crt/server.crt
+SSLCertificateFile "/usr/local/apache2/conf/ssl.crt/server.crt"
</highlight>
</example>
</usage>
<example><title>Example</title>
<highlight language="config">
-SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server.key
+SSLCertificateKeyFile "/usr/local/apache2/conf/ssl.key/server.key"
</highlight>
</example>
</usage>
confused in this situation.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCertificateChainFile /usr/local/apache2/conf/ssl.crt/ca.crt
+SSLCertificateChainFile "/usr/local/apache2/conf/ssl.crt/ca.crt"
</highlight>
</example>
</usage>
contains the appropriate symbolic links.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCACertificatePath /usr/local/apache2/conf/ssl.crt/
+SSLCACertificatePath "/usr/local/apache2/conf/ssl.crt/"
</highlight>
</example>
</usage>
<directive module="mod_ssl">SSLCACertificatePath</directive>.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCACertificateFile /usr/local/apache2/conf/ssl.crt/ca-bundle-client.crt
+SSLCACertificateFile "/usr/local/apache2/conf/ssl.crt/ca-bundle-client.crt"
</highlight>
</example>
</usage>
<example><title>Example</title>
<highlight language="config">
-SSLCADNRequestFile /usr/local/apache2/conf/ca-names.crt
+SSLCADNRequestFile "/usr/local/apache2/conf/ca-names.crt"
</highlight>
</example>
</usage>
this directory contains the appropriate symbolic links.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCADNRequestPath /usr/local/apache2/conf/ca-names.crt/
+SSLCADNRequestPath "/usr/local/apache2/conf/ca-names.crt/"
</highlight>
</example>
</usage>
contains the appropriate symbolic links.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCARevocationPath /usr/local/apache2/conf/ssl.crl/
+SSLCARevocationPath "/usr/local/apache2/conf/ssl.crl/"
</highlight>
</example>
</usage>
module="mod_ssl">SSLCARevocationPath</directive>.</p>
<example><title>Example</title>
<highlight language="config">
-SSLCARevocationFile /usr/local/apache2/conf/ssl.crl/ca-bundle-client.crl
+SSLCARevocationFile "/usr/local/apache2/conf/ssl.crl/ca-bundle-client.crl"
</highlight>
</example>
</usage>
</note>
<example><title>Example</title>
<highlight language="config">
-SSLProxyMachineCertificatePath /usr/local/apache2/conf/proxy.crt/
+SSLProxyMachineCertificatePath "/usr/local/apache2/conf/proxy.crt/"
</highlight>
</example>
</usage>
</note>
<example><title>Example</title>
<highlight language="config">
-SSLProxyMachineCertificateFile /usr/local/apache2/conf/ssl.crt/proxy.pem
+SSLProxyMachineCertificateFile "/usr/local/apache2/conf/ssl.crt/proxy.pem"
</highlight>
</example>
</usage>
</note>
<example><title>Example</title>
<highlight language="config">
-SSLProxyMachineCertificateChainFile /usr/local/apache2/conf/ssl.crt/proxyCA.pem
+SSLProxyMachineCertificateChainFile "/usr/local/apache2/conf/ssl.crt/proxyCA.pem"
</highlight>
</example>
</usage>
contains the appropriate symbolic links.</p>
<example><title>Example</title>
<highlight language="config">
-SSLProxyCACertificatePath /usr/local/apache2/conf/ssl.crt/
+SSLProxyCACertificatePath "/usr/local/apache2/conf/ssl.crt/"
</highlight>
</example>
</usage>
<directive module="mod_ssl">SSLProxyCACertificatePath</directive>.</p>
<example><title>Example</title>
<highlight language="config">
-SSLProxyCACertificateFile /usr/local/apache2/conf/ssl.crt/ca-bundle-remote-server.crt
+SSLProxyCACertificateFile "/usr/local/apache2/conf/ssl.crt/ca-bundle-remote-server.crt"
</highlight>
</example>
</usage>
contains the appropriate symbolic links.</p>
<example><title>Example</title>
<highlight language="config">
-SSLProxyCARevocationPath /usr/local/apache2/conf/ssl.crl/
+SSLProxyCARevocationPath "/usr/local/apache2/conf/ssl.crl/"
</highlight>
</example>
</usage>
module="mod_ssl">SSLProxyCARevocationPath</directive>.</p>
<example><title>Example</title>
<highlight language="config">
-SSLProxyCARevocationFile /usr/local/apache2/conf/ssl.crl/ca-bundle-remote-server.crl
+SSLProxyCARevocationFile "/usr/local/apache2/conf/ssl.crl/ca-bundle-remote-server.crl"
</highlight>
</example>
</usage>
<highlight language="config">
SSLVerifyClient on
SSLOCSPEnable on
-SSLOCSPDefaultResponder http://responder.example.com:8888/responder
+SSLOCSPDefaultResponder "http://responder.example.com:8888/responder"
SSLOCSPOverrideResponder on
</highlight>
</example>
<highlight language="config">
SSLOpenSSLConfCmd Options -SessionTicket,ServerPreference
SSLOpenSSLConfCmd ECDHParameters brainpoolP256r1
-SSLOpenSSLConfCmd ServerInfoFile /usr/local/apache2/conf/server-info.pem
+SSLOpenSSLConfCmd ServerInfoFile "/usr/local/apache2/conf/server-info.pem"
SSLOpenSSLConfCmd Protocol "-ALL, TLSv1.2"
SSLOpenSSLConfCmd SignatureAlgorithms RSA+SHA384:ECDSA+SHA256
</highlight>
domain add this code to your <code>httpd.conf</code>
configuration file</p>
<highlight language="config">
-<Location /server-status>
+<Location "/server-status">
SetHandler server-status
Require host example.com
</Location>
<example><title>Example</title>
<highlight language="config">
-<Location />
+<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
- Substitute s/foo/bar/ni
+ Substitute "s/foo/bar/ni"
</Location>
</highlight>
</example>
<example><title>Example of using an alternate delimiter</title>
<highlight language="config">
-<Location />
+<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<BR */?>|<br />|i"
</Location>
when regular expressions are used, as illustrated in the following example: </p>
<example><title>Example of using backreferences and captures</title>
<highlight language="config">
-<Location />
+<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
# "foo=k,bar=k" -> "foo/bar=k"
Substitute "s|foo=(\w+),bar=\1|foo/bar=$1"
<example><title>Rewriting URLs embedded in proxied content</title>
<highlight language="config">
-ProxyPass /blog/ http://internal.blog.example.com
-ProxyPassReverse /blog/ http://internal.blog.example.com/
+ProxyPass "/blog/" "http://internal.blog.example.com"
+ProxyPassReverse "/blog/" "http://internal.blog.example.com/"
Substitute "s|http://internal.blog.example.com/|http://www.example.com/blog/|i"
</highlight>
<example><title>Example</title>
<highlight language="config">
-<Location />
+<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
SubstituteMaxLineLength 10m
- Substitute s/foo/bar/ni
+ Substitute "s/foo/bar/ni"
</Location>
</highlight>
</example>
/usr/local/apache2/cgi-bin/script.pl</code> in all cases:</p>
<highlight language="config">
-ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
-VirtualScriptAlias /never/found/%0/cgi-bin/
+ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/"
+VirtualScriptAlias "/never/found/%0/cgi-bin/"
</highlight>
</note>
</summary>
<highlight language="config">
UseCanonicalName Off
-VirtualDocumentRoot /usr/local/apache/vhosts/%0
+VirtualDocumentRoot "/usr/local/apache/vhosts/%0"
</highlight>
<p>A request for
<highlight language="config">
UseCanonicalName Off
-VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2
+VirtualDocumentRoot "/usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2"
</highlight>
<p>A request for
end of the name, for example: </p>
<highlight language="config">
- VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2
+ VirtualDocumentRoot "/usr/local/apache/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2"
</highlight>
<p>The example request would come from
<p>Alternatively you might use: </p>
<highlight language="config">
- VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+
+ VirtualDocumentRoot "/usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+"
</highlight>
<p>The example request would come from
<highlight language="config">
UseCanonicalName DNS
-VirtualDocumentRootIP /usr/local/apache/vhosts/%1/%2/%3/%4/docs
-VirtualScriptAliasIP /usr/local/apache/vhosts/%1/%2/%3/%4/cgi-bin
+VirtualDocumentRootIP "/usr/local/apache/vhosts/%1/%2/%3/%4/docs"
+VirtualScriptAliasIP "/usr/local/apache/vhosts/%1/%2/%3/%4/cgi-bin"
</highlight>
<p>A request for
the following way:</p>
<highlight language="config">
- VirtualDocumentRoot /usr/local/apache/vhosts/%2.0.%3.0
+ VirtualDocumentRoot "/usr/local/apache/vhosts/%2.0.%3.0"
</highlight>
<p>A request for
<highlight language="config">
RewriteEngine On
RewriteMap lowercase int:tolower
-RewriteCond %{REQUEST_URI} [A-Z]
-RewriteRule (.*) ${lowercase:$1} [R,L]
+RewriteCond "%{REQUEST_URI}" "[A-Z]"
+RewriteRule "(.*)" "${lowercase:$1}" [R,L]
</highlight></li>
<li><p>When running, Apache needs write access only to the logs
<dl>
<dt>Mapped drive letters</dt>
- <dd>e.g., <code>Alias /images/ Z:/</code></dd>
+ <dd>e.g., <code>Alias "/images/" "Z:/"</code></dd>
<dt>UNC paths</dt>
- <dd>e.g., <code>Alias /images/ //imagehost/www/images/</code></dd>
+ <dd>e.g., <code>Alias "/images/" "//imagehost/www/images/"</code></dd>
</dl>
<p>Mapped drive letters allow the administrator to maintain the
<example><title>Example DocumentRoot with UNC path</title>
<highlight language="config">
- DocumentRoot //dochost/www/html/
+ DocumentRoot "//dochost/www/html/"
</highlight>
</example>
<example><title>Example DocumentRoot with IP address in UNC path</title>
<highlight language="config">
- DocumentRoot //192.168.1.50/docs/
+ DocumentRoot "//192.168.1.50/docs/"
</highlight>
</example>
<example><title>Example Alias and corresponding Directory with UNC path</title>
<highlight language="config">
-Alias /images/ //imagehost/www/images/
+Alias "/images/" "//imagehost/www/images/"
-<Directory //imagehost/www/images/>
+<Directory "//imagehost/www/images/">
#...
<Directory>
</highlight>
<!-- 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
accomplished without the use of mod_rewrite:</p>
<highlight language="config">
-SetEnvIf Referer example\.com localreferer
-<FilesMatch \.(jpg|png|gif)$>
+SetEnvIf Referer "example\.com" localreferer
+<FilesMatch "\.(jpg|png|gif)$">
Require env localreferer
</FilesMatch>
</highlight>
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>
same end using alternate means, as illustrated here:
</p>
<highlight language="config">
-SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
-<Location /secret/files>
+SetEnvIfNoCase User-Agent "^NameOfBadRobot" goaway
+<Location "/secret/files">
<RequireAll>
Require all granted
Require not env goaway
<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
<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
<highlight language="config">
<VirtualHost *:80>
ServerName www.example.com
- Redirect / https://www.example.com/
+ Redirect "/" "https://www.example.com/"
</VirtualHost >
<VirtualHost *:443>
and performance.</p>
<example><title>Using Alias</title>
-<highlight language="config">Alias /cats /var/www/virtualhosts/felines/htdocs</highlight>
+<highlight language="config">Alias "/cats" "/var/www/virtualhosts/felines/htdocs"</highlight>
</example>
<p>
<module>mod_proxy</module>.</p>
<highlight language="config">
-RewriteRule ^/?images(.*) http://imageserver.local/images$1 [P]
+RewriteRule "^/?images(.*)" "http://imageserver.local/images$1" [P]
</highlight>
<p>However, in many cases, when there is no actual pattern matching
The example here could be rendered as:</p>
<highlight language="config">
-ProxyPass /images/ http://imageserver.local/images/
+ProxyPass "/images/" "http://imageserver.local/images/"
</highlight>
<p>Note that whether you use <directive
catch redirects issued from the back-end server:</p>
<highlight language="config">
-ProxyPassReverse /images/ http://imageserver.local/images/
+ProxyPassReverse "/images/" "http://imageserver.local/images/"
</highlight>
<p>You may need to use <code>RewriteRule</code> instead when there are
<highlight language="config">
<If "req('Host') != 'www.example.com'">
- Redirect / http://www.example.com/
+ Redirect "/" "http://www.example.com/"
</If>
</highlight>
its behavior modified by one or more flags. Flags are included in
square brackets at the end of the rule, and multiple flags are separated
by commas.</p>
-<highlight language="config">RewriteRule pattern target [Flag1,Flag2,Flag3]</highlight>
+<highlight language="config">
+RewriteRule pattern target [Flag1,Flag2,Flag3]
+</highlight>
<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>.
Using the B flag, non-alphanumeric characters in backreferences
will be escaped. For example, consider the rule:</p>
-<highlight language="config">RewriteRule ^search/(.*)$ /search.php?term=$1</highlight>
+<highlight language="config">
+RewriteRule "^search/(.*)$" "/search.php?term=$1"
+</highlight>
<p>Given a search term of 'x & y/z', a browser will encode it as
'x%20%26%20y%2Fz', making the request 'search/x%20%26%20y%2Fz'. Without the B
<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
<p>The following rule will forbid <code>.exe</code> files from being
downloaded from your server.</p>
-<highlight language="config">RewriteRule \.exe - [F]</highlight>
+<highlight language="config">
+RewriteRule "\.exe" "-" [F]
+</highlight>
<p>This example uses the "-" syntax for the rewrite target, which means
that the requested URI is not modified. There's no reason to rewrite to
<p>As with the [F] flag, you will typically use the "-" syntax for the
rewrite target when using the [G] flag:</p>
-<highlight language="config">RewriteRule oldproduct - [G,NC]</highlight>
+<highlight language="config">
+RewriteRule "oldproduct" "-" [G,NC]
+</highlight>
<p>When using [G], an [L] is implied - that is, the response is returned
immediately, and no further rules are evaluated.</p>
handler. For example, one might use this to force all files without a
file extension to be parsed by the php handler:</p>
-<highlight language="config">RewriteRule !\. - [H=application/x-httpd-php]</highlight>
+<highlight language="config">
+RewriteRule "!\." "-" [H=application/x-httpd-php]
+</highlight>
<p>
The regular expression above - <code>!\.</code> - will match any request
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>
will replace A with B everywhere in a request, and will continue doing
so until there are no more As to be replaced.
</p>
-<highlight language="config">RewriteRule (.*)A(.*) $1B$2 [N]</highlight>
+<highlight language="config">
+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
<code>A</code>), perform this substitution (i.e., replace the
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=64000]
+RewriteRule "(.+)[><;]$" "$1" [N=64000]
# ... or, give up if after 10 loops
-RewriteRule (.+)[><;]$ $1 [N=10]
+RewriteRule "(.+)[><;]$" "$1" [N=10]
</highlight>
</section>
<code>.jpg</code> and <code>.JPG</code> files are both acceptable, for
example.</p>
-<highlight language="config">RewriteRule (.*\.(jpg|gif|png))$ http://images.example.com$1 [P,NC]</highlight>
+<highlight language="config">
+RewriteRule "(.*\.(jpg|gif|png))$" "http://images.example.com$1" [P,NC]
+</highlight>
</section>
<section id="flag_ne"><title>NE|noescape</title>
equivalent. Using the [NE] flag prevents that from happening.
</p>
-<highlight language="config">RewriteRule ^/anchor/(.+) /bigpage.html#$1 [NE,R]</highlight>
+<highlight language="config">
+RewriteRule "^/anchor/(.+)" "/bigpage.html#$1" [NE,R]
+</highlight>
<p>
The above example will redirect <code>/anchor/xyz</code> to
example, if you wanted all image requests to be handled by a back-end
image server, you might do something like the following:</p>
-<highlight language="config">RewriteRule /(.*)\.(jpg|gif|png)$ http://images.example.com/$1.$2 [P]</highlight>
+<highlight language="config">
+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
pushed through the proxy, and any following rules will not be
</p>
<highlight language="config">
-Alias /icons /usr/local/apache/icons
-RewriteRule /pics/(.+)\.jpg$ /icons/$1.gif [PT]
+Alias "/icons" "/usr/local/apache/icons"
+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]</highlight>
+<highlight language="config">
+RewriteRule "/pages/(.+)" "/page.php?page=$1" [QSA]
+</highlight>
<p>With the [QSA] flag, a request for <code>/pages/123?one=two</code> will be
mapped to <code>/page.php?page=123&one=two</code>. Without the [QSA]
<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
<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>
<highlight language="config">
RewriteEngine on
-RewriteBase /products/
-RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P]
-ProxyPassReverse /products/widget/ http://product.example.com/widget/
+RewriteBase "/products/"
+RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P]
+ProxyPassReverse "/products/widget/" "http://product.example.com/widget/"
</highlight>
<p>In the second example, we proxy the request only if we can't find
has been migrated yet.</p>
<highlight language="config">
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^/(.*) http://old.example.com/$1 [P]
-ProxyPassReverse / http://old.example.com/
+RewriteCond "%{REQUEST_FILENAME}" !-f
+RewriteCond "%{REQUEST_FILENAME}" !-d
+RewriteRule "^/(.*)" "http://old.example.com/$1" [P]
+ProxyPassReverse "/" "http://old.example.com/"
</highlight>
</dd>
<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>
use the Redirect directive. mod_rewrite was used in that earlier
example in order to hide the redirect from the client:</p>
- <highlight language="config">Redirect /foo.html /bar.html</highlight>
+ <highlight language="config">
+Redirect "/foo.html" "/bar.html"
+ </highlight>
</dd>
</dl>
to the new server, but you might also consider using the Redirect
or RedirectMatch directive.</p>
-<highlight language="config">#With mod_rewrite
+<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">#With RedirectMatch
-RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1
+<highlight language="config">
+#With RedirectMatch
+RedirectMatch "^/docs/(.*)" "http://new.example.com/docs/$1"
</highlight>
-<highlight language="config">#With Redirect
-Redirect /docs/ http://new.example.com/docs/
+<highlight language="config">
+#With Redirect
+Redirect "/docs/" "http://new.example.com/docs/"
</highlight>
</dd>
</dl>
<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>
# backward compatibility ruleset for
# rewriting document.html to document.php
# when and only when document.php exists
-<Directory /var/www/htdocs>
+<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>
ServerName undesired.example.com
ServerAlias example.com notthis.example.com
- Redirect / http://www.example.com/
+ Redirect "/" "http://www.example.com/"
</VirtualHost>
<VirtualHost *:80>
<highlight language="config">
<If "%{HTTP_HOST} != 'www.example.com'">
- Redirect / http://www.example.com/
+ Redirect "/" "http://www.example.com/"
</If>
</highlight>
<highlight language="config">
<If "%{SERVER_PROTOCOL} != 'HTTPS'">
- Redirect /admin/ https://www.example.com/admin/
+ Redirect "/admin/" "https://www.example.com/admin/"
</If>
</highlight>
<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>
This is done with the following ruleset:</p>
<highlight language="config">
-RewriteCond %{HTTP_USER_AGENT} ^<strong>Mozilla/3</strong>.*
-RewriteRule ^foo\.html$ foo.<strong>NS</strong>.html [<strong>L</strong>]
+RewriteCond "%{HTTP_USER_AGENT}" "^<strong>Mozilla/3</strong>.*"
+RewriteRule "^foo\.html$" "foo.<strong>NS</strong>.html" [<strong>L</strong>]
-RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR]
-RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12]
-RewriteRule ^foo\.html$ foo.<strong>20</strong>.html [<strong>L</strong>]
+RewriteCond "%{HTTP_USER_AGENT}" "^Lynx/" [OR]
+RewriteCond "%{HTTP_USER_AGENT}" "^Mozilla/[12]"
+RewriteRule "^foo\.html$" "foo.<strong>20</strong>.html" [<strong>L</strong>]
-RewriteRule ^foo\.html$ foo.<strong>32</strong>.html [<strong>L</strong>]
+RewriteRule "^foo\.html$" "foo.<strong>32</strong>.html" [<strong>L</strong>]
</highlight>
</dd>
</dl>
we replace <code>/puppies</code> and <code>/canines</code>
by the canonical <code>/dogs</code>.</p>
-<highlight language="config">RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]</highlight>
+<highlight language="config">
+RewriteRule "^/(puppies|canines)/(.*)" "/dogs/$2" [R]
+</highlight>
</dd>
<dt>Discussion:</dt>
This should really be accomplished with Redirect or RedirectMatch
directives:
- <highlight language="config"> RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2 </highlight>
+ <highlight language="config">
+RedirectMatch "^/(puppies|canines)/(.*)" "/dogs/$2"
+</highlight>
</dd>
</dl>
<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
module="mod_alias">RedirectMatch</directive> directive:</p>
-<highlight language="config">RedirectMatch ^/$ http://example.com/about/</highlight>
+<highlight language="config">
+RedirectMatch "^/$" "http://example.com/about/"
+</highlight>
<p>Note also that the example rewrites only the root URL. That is, it
rewrites a request for <code>http://example.com/</code>, but not a
module="mod_dir">FallbackResource</directive> directive for this:</p>
<highlight language="config">
-<Directory /var/www/my_blog>
- FallbackResource index.php
+<Directory "/var/www/my_blog">
+ FallbackResource "index.php"
</Directory>
</highlight>
set to accomplish the same thing:</p>
<highlight language="config">
-<Directory /var/www/my_blog>
- RewriteBase /my_blog
+<Directory "/var/www/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>
<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>
-<highlight language="config">RewriteRule (.*) index.php?$1 [PT,QSA]</highlight>
+<highlight language="config">
+RewriteRule "(.*)" "index.php?$1" [PT,QSA]
+</highlight>
<p>Note that these rulesets can be used in a <code>.htaccess</code>
file, as well as in a <Directory> block.</p>
<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>
-<highlight language="config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></highlight>
+<highlight language="config">
+RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
+</highlight>
<p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an
arbitray name that you assign to the map, and which you will use in
<p>For example, you might define a
<directive>RewriteMap</directive> as:</p>
- <highlight language="config">RewriteMap examplemap txt:/path/to/file/map.txt</highlight>
+ <highlight language="config">
+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}</highlight>
+<highlight language="config">
+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}</highlight>
+<highlight language="config">
+RewriteRule "^/ex/(.*)" "${examplemap:$1|/not_found.html}"
+</highlight>
<note><title>Per-directory and .htaccess context</title>
<p>
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
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:
- <highlight language="config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</highlight>
+ <highlight language="config">
+RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]
+</highlight>
</note>
<note><title>Cached lookups</title>
</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>
<highlight language="config">
RewriteMap lc int:tolower
-RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]
+RewriteRule "(.*?[A-Z]+.*)" "${lc:$1}" [R]
</highlight>
<note>
<p><strong>Rewrite configuration</strong></p>
<highlight language="config">
-RewriteMap d2u prg:/www/bin/dash2under.pl<br />
-RewriteRule - ${d2u:%{REQUEST_URI}}
+RewriteMap d2u "prg:/www/bin/dash2under.pl"<br />
+RewriteRule "-" "${d2u:%{REQUEST_URI}}"
</highlight>
<p><strong>dash2under.pl</strong></p>
<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>
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>
# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
-<Directory /www/hosts>
+<Directory "/www/hosts">
# ExecCGI is needed here because we can't force
# CGI execution in the way that ScriptAlias does
Options FollowSymLinks ExecCGI
RewriteMap lowercase int:tolower
## deal with normal documents first:
-# allow Alias /icons/ to work - repeat for other aliases
-RewriteCond %{REQUEST_URI} !^/icons/
+# allow Alias "/icons/" to work - repeat for other aliases
+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>
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>
<highlight language="config">
<IfDefine ClosedForNow>
- Redirect / http://otherserver.example.com/
+ Redirect "/" "http://otherserver.example.com/"
</IfDefine>
</highlight>
<highlight language="config">
<IfModule mod_mime_magic.c>
- MimeMagicFile conf/magic
+ MimeMagicFile "conf/magic"
</IfModule>
</highlight>
<code>/var/web/dir1</code> directory and all subdirectories.</p>
<highlight language="config">
-<Directory /var/web/dir1>
+<Directory "/var/web/dir1">
Options +Indexes
</Directory>
</highlight>
of where it is found.</p>
<highlight language="config">
-<Files private.html>
+<Files "private.html">
Require all denied
</Files>
</highlight>
directory.</p>
<highlight language="config">
-<Directory /var/web/dir1>
- <Files private.html>
+<Directory "/var/web/dir1">
+ <Files "private.html">
Require all denied
</Files>
</Directory>
as any other requests starting with the <code>/private</code> string.</p>
<highlight language="config">
-<LocationMatch ^/private>
+<LocationMatch "^/private">
Require all denied
</LocationMatch>
</highlight>
filesystem.</p>
<highlight language="config">
-<Location /server-status>
+<Location "/server-status">
SetHandler server-status
</Location>
</highlight>
certain sections or directives are evaluated. For
<directive type="section" module="core">Location</directive> this would be:</p>
<highlight language="config">
-<Location /foo>
+<Location "/foo">
</Location>
-<Location /foo/bar>
+<Location "/foo/bar">
</Location>
</highlight>
<p><directive type="section" module="mod_alias">Alias</directive>es on the other hand,
are mapped vice-versa:</p>
<highlight language="config">
-Alias /foo/bar /srv/www/uncommon/bar
-Alias /foo /srv/www/common/foo
+Alias "/foo/bar" "/srv/www/uncommon/bar"
+Alias "/foo" "/srv/www/common/foo"
</highlight>
<p>The same is true for the <directive module="mod_proxy">ProxyPass</directive>
directives:</p>
<highlight language="config">
-ProxyPass /special-area http://special.example.com smax=5 max=10
-ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On
+ProxyPass "/special-area" "http://special.example.com" smax=5 max=10
+ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofailover=On
</highlight>
</section>
all user directories could look as follows:</p>
<highlight language="config">
-<Directory /home/*/public_html>
+<Directory "/home/*/public_html">
Options Indexes
</Directory>
</highlight>
<p>Using regex sections, we can deny access to many types of image files
at once:</p>
<highlight language="config">
-<FilesMatch \.(?i:gif|jpe?g|png)$>
+<FilesMatch "\.(?i:gif|jpe?g|png)$">
Require all denied
</FilesMatch>
</highlight>
and modules like <module>mod_rewrite</module>.</p>
<highlight language="config">
-<DirectoryMatch ^/var/www/combined/(?<SITENAME>[^/]+)>
- require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
+<DirectoryMatch "^/var/www/combined/(?<SITENAME>[^/]+)">
+ require ldap-group "cn=%{env:MATCH_SITENAME},ou=combined,o=Example"
</DirectoryMatch>
</highlight>
For example, consider the following configuration:</p>
<highlight language="config">
-<Location /dir/>
+<Location "/dir/">
Require all denied
</Location>
</highlight>
filesystem location. Therefore you should always use the filesystem
containers when you can. There is, however, one exception to this
rule. Putting configuration restrictions in a <code><Location
-/></code> section is perfectly safe because this section will apply
+"/"></code> section is perfectly safe because this section will apply
to all requests regardless of the specific URL.</p>
</section>
<code>www.example.com</code> website.</p>
<highlight language="config">
-<Proxy http://www.example.com/*>
+<Proxy "http://www.example.com/*">
Require all granted
</Proxy>
</highlight>
<directive type="section" module="core">Directory</directive>)</li>
<li><directive type="section" module="core">DirectoryMatch</directive>
- (and <code><Directory ~></code>)</li>
+ (and <code><Directory "~"></code>)</li>
<li><directive type="section"
module="core">Files</directive> and <directive
the order that they appear in the configuration files. <directive
type="section" module="core">Directory</directive> (group 1 above)
is processed in the order shortest directory component to longest.
- So for example, <code><Directory /var/web/dir></code> will
+ So for example, <code><Directory "/var/web/dir"></code> will
be processed before <code><Directory
- /var/web/dir/subdir></code>. If multiple <directive
+ "/var/web/dir/subdir"></code>. If multiple <directive
type="section" module="core">Directory</directive> sections apply
to the same directory they are processed in the configuration file
order. Configurations included via the <directive
E.</p>
<highlight language="config">
-<Location />
+<Location "/">
E
</Location>
-<Files f.html>
+<Files "f.html">
D
</Files>
<VirtualHost *>
-<Directory /a/b>
+<Directory "/a/b">
B
</Directory>
</VirtualHost>
C
</DirectoryMatch>
-<Directory /a/b>
+<Directory "/a/b">
A
</Directory>
other words, order of merging is important, so be careful!</p>
<highlight language="config">
-<Location />
+<Location "/">
Require all granted
</Location>
# Woops! This <Directory> section will have no effect
-<Directory />
+<Directory "/">
<RequireAll>
Require all granted
Require not host badguy.example.com
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
These can be used as follows in your <code>httpd.conf</code>
file:
<highlight language="config">
-SSLCertificateFile /path/to/this/server.crt
-SSLCertificateKeyFile /path/to/this/server.key
+SSLCertificateFile "/path/to/this/server.crt"
+SSLCertificateKeyFile "/path/to/this/server.key"
</highlight>
</li>
<li>It is important that you are aware that this
<code>server.crt</code>. These can be used as follows in your
<code>httpd.conf</code> file:
<highlight language="config">
-SSLCertificateFile /path/to/this/server.crt
-SSLCertificateKeyFile /path/to/this/server.key
+SSLCertificateFile "/path/to/this/server.crt"
+SSLCertificateKeyFile "/path/to/this/server.key"
</highlight>
The <code>server.csr</code> file is no longer needed.
</li>
<VirtualHost *:443>
ServerName www.example.com
SSLEngine on
- SSLCertificateFile /path/to/www.example.com.cert
- SSLCertificateKeyFile /path/to/www.example.com.key
+ SSLCertificateFile "/path/to/www.example.com.cert"
+ SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>
</highlight>
# be liberal in general
SSLCipherSuite ALL:!aNULL:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
-<Location /strong/area>
+<Location "/strong/area">
# but https://hostname/strong/area/ and below
# requires strong ciphers
SSLCipherSuite HIGH:!aNULL:!MD5
# signed by our CA certificate in ca.crt
SSLVerifyClient require
SSLVerifyDepth 1
-SSLCACertificateFile conf/ssl.crt/ca.crt
+SSLCACertificateFile "conf/ssl.crt/ca.crt"
</highlight>
</section>
<highlight language="config">
SSLVerifyClient none
-SSLCACertificateFile conf/ssl.crt/ca.crt
+SSLCACertificateFile "conf/ssl.crt/ca.crt"
-<Location /secure/area>
+<Location "/secure/area">
SSLVerifyClient require
SSLVerifyDepth 1
</Location>
<highlight language="config">
SSLVerifyClient none
-SSLCACertificateFile conf/ssl.crt/ca.crt
-SSLCACertificatePath conf/ssl.crt
+SSLCACertificateFile "conf/ssl.crt/ca.crt"
+SSLCACertificatePath "conf/ssl.crt"
-<Directory /usr/local/apache2/htdocs/secure/area>
+<Directory "/usr/local/apache2/htdocs/secure/area">
SSLVerifyClient require
SSLVerifyDepth 5
SSLOptions +FakeBasicAuth
AuthName "Snake Oil Authentication"
AuthType Basic
AuthBasicProvider file
- AuthUserFile /usr/local/apache2/conf/httpd.passwd
+ AuthUserFile "/usr/local/apache2/conf/httpd.passwd"
Require valid-user
</Directory>
</highlight>
<highlight language="config">
SSLVerifyClient none
-SSLCACertificateFile conf/ssl.crt/ca.crt
-SSLCACertificatePath conf/ssl.crt
+SSLCACertificateFile "conf/ssl.crt/ca.crt"
+SSLCACertificatePath "conf/ssl.crt"
-<Directory /usr/local/apache2/htdocs/secure/area>
+<Directory "/usr/local/apache2/htdocs/secure/area">
SSLVerifyClient require
SSLVerifyDepth 5
SSLOptions +FakeBasicAuth
that it applies to both HTTPS and HTTP.</p>
<highlight language="config">
-SSLCACertificateFile conf/ssl.crt/company-ca.crt
+SSLCACertificateFile "conf/ssl.crt/company-ca.crt"
-<Directory /usr/local/apache2/htdocs>
+<Directory "/usr/local/apache2/htdocs">
# Outside the subarea only Intranet access is granted
Require ip 192.168.1.0/24
</Directory>
-<Directory /usr/local/apache2/htdocs/subarea>
+<Directory "/usr/local/apache2/htdocs/subarea">
# Inside the subarea any Intranet access is allowed
# but from the Internet only HTTPS + Strong-Cipher + Password
# or the alternative HTTPS + Strong-Cipher + Client-Certificate
# Force clients from the Internet to use HTTPS
RewriteEngine on
- RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.[0-9]+$
- RewriteCond %{HTTPS} !=on
- RewriteRule . - [F]
+ RewriteCond "%{REMOTE_ADDR}" "!^192\.168\.1\.[0-9]+$"
+ RewriteCond "%{HTTPS}" "!=on"
+ RewriteRule "." "-" [F]
# Allow Network Access and/or Basic Auth
Satisfy any
AuthType basic
AuthName "Protected Intranet Area"
AuthBasicProvider file
- AuthUserFile conf/protected.passwd
+ AuthUserFile "conf/protected.passwd"
Require valid-user
</Directory>
</highlight>
module="mod_alias">Alias</directive> directive will map any part
of the filesystem into the web space. For example, with</p>
-<highlight language="config">Alias /docs /var/web</highlight>
+<highlight language="config">
+Alias "/docs" "/var/web"
+</highlight>
<p>the URL <code>http://www.example.com/docs/dir/file.html</code>
will be served from <code>/var/web/dir/file.html</code>. The
example,</p>
<highlight language="config">
- ScriptAliasMatch ^/~([a-zA-Z0-9]+)/cgi-bin/(.+) /home/$1/cgi-bin/$2
+ ScriptAliasMatch "^/~([a-zA-Z0-9]+)/cgi-bin/(.+)" "/home/$1/cgi-bin/$2"
</highlight>
<p>will map a request to
<code>AliasMatch</code> directive:</p>
<highlight language="config">
- AliasMatch ^/upages/([a-zA-Z0-9]+)(/(.*))?$ /home/$1/public_html/$3
+ AliasMatch "^/upages/([a-zA-Z0-9]+)(/(.*))?$" "/home/$1/public_html/$3"
</highlight>
</section>
to request the content at the new location as follows:</p>
<highlight language="config">
- Redirect permanent /foo/ http://www.example.com/bar/
+ Redirect permanent "/foo/" "http://www.example.com/bar/"
</highlight>
<p>This will redirect any URL-Path starting in
requests alone, use the following configuration:</p>
<highlight language="config">
- RedirectMatch permanent ^/$ http://www.example.com/startpage.html
+ RedirectMatch permanent "^/$" "http://www.example.com/startpage.html"
</highlight>
<p>Alternatively, to temporarily redirect all pages on one site
to a particular page on another site, use the following:</p>
<highlight language="config">
- RedirectMatch temp .* http://othersite.example.com/startpage.html
+ RedirectMatch temp ".*" "http://othersite.example.com/startpage.html"
</highlight>
</section>
server.</p>
<highlight language="config">
-ProxyPass /foo/ http://internal.example.com/bar/<br />
-ProxyPassReverse /foo/ http://internal.example.com/bar/<br />
+ProxyPass "/foo/" "http://internal.example.com/bar/"<br />
+ProxyPassReverse "/foo/" "http://internal.example.com/bar/"<br />
ProxyPassReverseCookieDomain internal.example.com public.example.com<br />
-ProxyPassReverseCookiePath /foo/ /bar/
+ProxyPassReverseCookiePath "/foo/" "/bar/"
</highlight>
<p>The <directive module="mod_proxy">ProxyPass</directive> configures
<module>mod_substitute</module>.</p>
<highlight language="config">
-Substitute s/internal\.example\.com/www.example.com/i
+Substitute "s/internal\.example\.com/www.example.com/i"
</highlight>
<p>For more sophisticated rewriting of links in HTML and XHTML, the
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
- DocumentRoot /www/example1
+ DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
# This is the "main" server running on 172.20.30.40
ServerName server.example.com
-DocumentRoot /www/mainserver
+DocumentRoot "/www/mainserver"
<VirtualHost 172.20.30.50>
- DocumentRoot /www/example1
+ DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here ...
</VirtualHost>
<VirtualHost 172.20.30.50>
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here ...
<highlight language="config">
<VirtualHost 192.168.1.1 172.20.30.40>
- DocumentRoot /www/server1
+ DocumentRoot "/www/server1"
ServerName server.example.com
ServerAlias server
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
- DocumentRoot /www/domain-80
+ DocumentRoot "/www/domain-80"
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
- DocumentRoot /www/domain-8080
+ DocumentRoot "/www/domain-8080"
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
- DocumentRoot /www/otherdomain-80
+ DocumentRoot "/www/otherdomain-80"
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
- DocumentRoot /www/otherdomain-8080
+ DocumentRoot "/www/otherdomain-8080"
</VirtualHost>
</highlight>
Listen 80
<VirtualHost 172.20.30.40>
- DocumentRoot /www/example1
+ DocumentRoot "/www/example1"
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.50>
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
ServerName www.example.org
</VirtualHost>
</highlight>
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
- DocumentRoot /www/example1-80
+ DocumentRoot "/www/example1-80"
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
- DocumentRoot /www/example1-8080
+ DocumentRoot "/www/example1-8080"
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
- DocumentRoot /www/example2-80
+ DocumentRoot "/www/example2-80"
ServerName www.example.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
- DocumentRoot /www/example2-8080
+ DocumentRoot "/www/example2-8080"
ServerName www.example.org
</VirtualHost>
</highlight>
<highlight language="config">
Listen 80
<VirtualHost 172.20.30.40>
- DocumentRoot /www/example1
+ DocumentRoot "/www/example1"
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.40>
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
ServerName www.example.org
</VirtualHost>
<VirtualHost 172.20.30.40>
- DocumentRoot /www/example3
+ DocumentRoot "/www/example3"
ServerName www.example.net
</VirtualHost>
# IP-based
<VirtualHost 172.20.30.50>
- DocumentRoot /www/example4
+ DocumentRoot "/www/example4"
ServerName www.example.edu
</VirtualHost>
<VirtualHost 172.20.30.60>
- DocumentRoot /www/example5
+ DocumentRoot "/www/example5"
ServerName www.example.gov
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost *:*>
ProxyPreserveHost On
- ProxyPass / http://192.168.111.2/
- ProxyPassReverse / http://192.168.111.2/
+ ProxyPass "/" "http://192.168.111.2/"
+ ProxyPassReverse "/" "http://192.168.111.2/"
ServerName hostname.example.com
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost _default_:*>
- DocumentRoot /www/default
+ DocumentRoot "/www/default"
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost _default_:80>
- DocumentRoot /www/default80
+ DocumentRoot "/www/default80"
# ...
</VirtualHost>
<VirtualHost _default_:*>
- DocumentRoot /www/default
+ DocumentRoot "/www/default"
# ...
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost _default_:80>
-DocumentRoot /www/default
+DocumentRoot "/www/default"
...
</VirtualHost>
</highlight>
<highlight language="config">
Listen 80
ServerName www.example.com
-DocumentRoot /www/example1
+DocumentRoot "/www/example1"
<VirtualHost 172.20.30.40 172.20.30.50>
- DocumentRoot /www/example2
+ DocumentRoot "/www/example2"
ServerName www.example.org
# ...
</VirtualHost>
<VirtualHost 172.20.30.40>
- DocumentRoot /www/example3
+ DocumentRoot "/www/example3"
ServerName www.example.net
ServerAlias *.example.net
# ...
<highlight language="config">
<VirtualHost 172.20.30.40>
# primary vhost
- DocumentRoot /www/subdomain
+ DocumentRoot "/www/subdomain"
RewriteEngine On
- RewriteRule . /www/subdomain/index.html
+ RewriteRule "." "/www/subdomain/index.html"
# ...
</VirtualHost>
<VirtualHost 172.20.30.40>
-DocumentRoot /www/subdomain/sub1
+DocumentRoot "/www/subdomain/sub1"
ServerName www.sub1.domain.tld
- ServerPath /sub1/
+ ServerPath "/sub1/"
RewriteEngine On
- RewriteRule ^(/sub1/.*) /www/subdomain$1
+ RewriteRule "^(/sub1/.*)" "/www/subdomain$1"
# ...
</VirtualHost>
<VirtualHost 172.20.30.40>
- DocumentRoot /www/subdomain/sub2
+ DocumentRoot "/www/subdomain/sub2"
ServerName www.sub2.domain.tld
- ServerPath /sub2/
+ ServerPath "/sub2/"
RewriteEngine On
- RewriteRule ^(/sub2/.*) /www/subdomain$1
+ RewriteRule "^(/sub2/.*)" "/www/subdomain$1"
# ...
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost 172.20.30.40:80>
ServerAdmin webmaster@www1.example.com
- DocumentRoot /www/vhosts/www1
+ DocumentRoot "/www/vhosts/www1"
ServerName www1.example.com
- ErrorLog /www/logs/www1/error_log
- CustomLog /www/logs/www1/access_log combined
+ ErrorLog "/www/logs/www1/error_log"
+ CustomLog "/www/logs/www1/access_log" combined
</VirtualHost>
<VirtualHost 172.20.30.50:80>
ServerAdmin webmaster@www2.example.org
- DocumentRoot /www/vhosts/www2
+ DocumentRoot "/www/vhosts/www2"
ServerName www2.example.org
- ErrorLog /www/logs/www2/error_log
- CustomLog /www/logs/www2/access_log combined
+ ErrorLog "/www/logs/www2/error_log"
+ CustomLog "/www/logs/www2/access_log" combined
</VirtualHost>
</highlight>
<highlight language="config">
<VirtualHost 111.22.33.44>
ServerName customer-1.example.com
- DocumentRoot /www/hosts/customer-1.example.com/docs
- ScriptAlias /cgi-bin/ /www/hosts/customer-1.example.com/cgi-bin
+ DocumentRoot "/www/hosts/customer-1.example.com/docs"
+ ScriptAlias "/cgi-bin/" "/www/hosts/customer-1.example.com/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-2.example.com
- DocumentRoot /www/hosts/customer-2.example.com/docs
- ScriptAlias /cgi-bin/ /www/hosts/customer-2.example.com/cgi-bin
+ DocumentRoot "/www/hosts/customer-2.example.com/docs"
+ ScriptAlias "/cgi-bin/" "/www/hosts/customer-2.example.com/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-N.example.com
- DocumentRoot /www/hosts/customer-N.example.com/docs
- ScriptAlias /cgi-bin/ /www/hosts/customer-N.example.com/cgi-bin
+ DocumentRoot "/www/hosts/customer-N.example.com/docs"
+ ScriptAlias "/cgi-bin/" "/www/hosts/customer-N.example.com/cgi-bin"
</VirtualHost>
</highlight>
# this log format can be split per-virtual-host based on the first field
# using the split-logfile utility.
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the server name in the filenames used to satisfy requests
-VirtualDocumentRoot /www/hosts/%0/docs
-VirtualScriptAlias /www/hosts/%0/cgi-bin
+VirtualDocumentRoot "/www/hosts/%0/docs"
+VirtualScriptAlias "/www/hosts/%0/cgi-bin"
</highlight>
<p>This configuration can be changed into an IP-based virtual
CustomLog logs/access_log vcommon
# include part of the server name in the filenames
-VirtualDocumentRoot /home/%2/www
+VirtualDocumentRoot "/home/%2/www"
# single cgi-bin directory
-ScriptAlias /cgi-bin/ /www/std-cgi/
+ScriptAlias "/cgi-bin/" "/www/std-cgi/"
</highlight>
<p>There are examples of more complicated
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
-<Directory /www/commercial>
+<Directory "/www/commercial">
Options FollowSymLinks
AllowOverride All
</Directory>
-<Directory /www/homepages>
+<Directory "/www/homepages">
Options FollowSymLinks
AllowOverride None
</Directory>
<VirtualHost 111.22.33.44>
ServerName www.commercial.example.com
- CustomLog logs/access_log.commercial vcommon
+ CustomLog "logs/access_log.commercial" vcommon
- VirtualDocumentRoot /www/commercial/%0/docs
- VirtualScriptAlias /www/commercial/%0/cgi-bin
+ 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
+ CustomLog "logs/access_log.homepages" vcommon
- VirtualDocumentRoot /www/homepages/%0/docs
- ScriptAlias /cgi-bin/ /www/std-cgi/
+ VirtualDocumentRoot "/www/homepages/%0/docs"
+ ScriptAlias "/cgi-bin/" "/www/std-cgi/"
</VirtualHost>
</highlight>
# include the IP address in the logs so they may be split
LogFormat "%A %h %l %u %t \"%r\" %s %b" vcommon
-CustomLog logs/access_log vcommon
+CustomLog "logs/access_log" vcommon
# include the IP address in the filenames
-VirtualDocumentRootIP /www/hosts/%0/docs
-VirtualScriptAliasIP /www/hosts/%0/cgi-bin
+VirtualDocumentRootIP "/www/hosts/%0/docs"
+VirtualScriptAliasIP "/www/hosts/%0/cgi-bin"
</highlight>
</section>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
- DocumentRoot /www/domain
+ DocumentRoot "/www/domain"
</VirtualHost>
<VirtualHost *:80>
ServerName other.example.com
- DocumentRoot /www/otherdomain
+ DocumentRoot "/www/otherdomain"
</VirtualHost>
</highlight>