FileInfo.</p>
<highlight language="config">
-ErrorDocument 500 "Sorry, our script crashed. Oh dear"<br />
-ErrorDocument 500 /cgi-bin/crash-recover<br />
-ErrorDocument 500 http://error.example.com/server_error.html<br />
-ErrorDocument 404 /errors/not_found.html <br />
+ErrorDocument 500 "Sorry, our script crashed. Oh dear"
+ErrorDocument 500 /cgi-bin/crash-recover
+ErrorDocument 500 http://error.example.com/server_error.html
+ErrorDocument 404 /errors/not_found.html
ErrorDocument 401 /subscription/how_to_subscribe.html
</highlight>
<highlight language="perl">
...
-print "Content-type: text/html\n"; <br />
-printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br />
+print "Content-type: text/html\n";
+printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"};
...
</highlight>
<p>In your server configuration file, you'll see a line such as:</p>
<highlight language="config">
- # Multi-language error messages<br />
- #Include conf/extra/httpd-multilang-errordoc.conf
+# Multi-language error messages
+#Include conf/extra/httpd-multilang-errordoc.conf
</highlight>
<p>Uncommenting this <code>Include</code> line will enable this
takes a <code>request_rec *</code> and an <code>int</code> and is
called <code>do_something</code>, then declare it like this:</p>
<highlight language="c">
- AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))
+AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))
</highlight>
<p>This should go in a header which modules will include if
hooks are called, and the caller is implemented like this:</p>
<highlight language="c">
- AP_IMPLEMENT_HOOK_VOID(do_something, (request_rec *r, int n), (r, n))
+AP_IMPLEMENT_HOOK_VOID(do_something, (request_rec *r, int n), (r, n))
</highlight>
<p>The second and third arguments are the dummy argument
the first hook that does something interesting, like so:</p>
<highlight language="c">
- AP_IMPLEMENT_HOOK_RUN_FIRST(int, do_something, (request_rec *r, int n), (r, n), DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, do_something, (request_rec *r, int n), (r, n), DECLINED)
</highlight>
<p>The first hook that does <em>not</em> return <code>DECLINED</code>
return is the return value. Declare these like so:</p>
<highlight language="c">
- AP_IMPLEMENT_HOOK_RUN_ALL(int, do_something, (request_rec *r, int n), (r, n), OK, DECLINED)
+AP_IMPLEMENT_HOOK_RUN_ALL(int, do_something, (request_rec *r, int n), (r, n), OK, DECLINED)
</highlight>
<p>Again, <code>OK</code> and <code>DECLINED</code> are the traditional
of the correct type:</p>
<highlight language="c">
-static int my_something_doer(request_rec *r, int n)<br />
+static int my_something_doer(request_rec *r, int n)
{
...
return OK;
<example><title>How to handle an empty brigade</title>
<highlight language="c">
- apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)<br />
- {
- if (APR_BRIGADE_EMPTY(bb)) {
- return APR_SUCCESS;
- }
- ....
+apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
+{
+ if (APR_BRIGADE_EMPTY(bb)) {
+ return APR_SUCCESS;
+ }
+ ...
</highlight>
</example>
apr_size_t length;
while ((e = APR_BRIGADE_FIRST(bb)) != APR_BRIGADE_SENTINEL(bb)) {
- rv = apr_bucket_read(e, &data, &length, APR_BLOCK_READ);
- if (rv) ...;
- /* Remove bucket e from bb. */
- APR_BUCKET_REMOVE(e);
- /* Insert it into temporary brigade. */
- APR_BRIGADE_INSERT_HEAD(tmpbb, e);
- /* Pass brigade downstream. */
- rv = ap_pass_brigade(f->next, tmpbb);
- if (rv) ...;
- apr_brigade_cleanup(tmpbb);
+ rv = apr_bucket_read(e, &data, &length, APR_BLOCK_READ);
+ if (rv) ...;
+ /* Remove bucket e from bb. */
+ APR_BUCKET_REMOVE(e);
+ /* Insert it into temporary brigade. */
+ APR_BRIGADE_INSERT_HEAD(tmpbb, e);
+ /* Pass brigade downstream. */
+ rv = ap_pass_brigade(f->next, tmpbb);
+ if (rv) ...;
+ apr_brigade_cleanup(tmpbb);
}
</highlight>
</example>
<example><title>Example code to maintain filter state</title>
<highlight language="c">
struct dummy_state {
- apr_bucket_brigade *tmpbb;
- int filter_state;
- ...
+ apr_bucket_brigade *tmpbb;
+ int filter_state;
+ ...
};
apr_status_t dummy_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
-
struct dummy_state *state;
state = f->ctx;
if (state == NULL) {
- /* First invocation for this response: initialise state structure.
- */
- f->ctx = state = apr_palloc(f->r->pool, sizeof *state);
-
- state->tmpbb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
- state->filter_state = ...;
+ /* First invocation for this response: initialise state structure.
+ */
+ f->ctx = state = apr_palloc(f->r->pool, sizeof *state);
+ state->tmpbb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
+ state->filter_state = ...;
}
...
</highlight>
/* Retry, using a blocking read. */
mode = APR_BLOCK_READ;
continue;
- } else if (rv != APR_SUCCESS) {
+ }
+ else if (rv != APR_SUCCESS) {
/* handle errors */
}
</Directory>
<Location "/">
- Options +IncludesNoExec -ExecCGI<br />
+ Options +IncludesNoExec -ExecCGI
</Location>
</highlight>
using a configuration like the following:</p>
<highlight language="config">
- UserDir disabled<br />
- UserDir enabled rbowen krietz
+UserDir disabled
+UserDir enabled rbowen krietz
</highlight>
<p>See <directive module="mod_userdir">UserDir</directive>
directive either in your <code>httpd.conf</code> file, or in a
<code>.htaccess</code> file:</p>
<highlight language="config">
- Options +Includes
+Options +Includes
</highlight>
<p>This tells Apache that you want to permit files to be parsed
particular file extension, such as <code>.shtml</code>, with
the following directives:</p>
<highlight language="config">
- AddType text/html .shtml<br />
- AddOutputFilter INCLUDES .shtml
+AddType text/html .shtml
+AddOutputFilter INCLUDES .shtml
</highlight>
<p>One disadvantage to this approach is that if you wanted to
<p>The other method is to use the <directive
module="mod_include">XBitHack</directive> directive:</p>
<highlight language="config">
- XBitHack on
+XBitHack on
</highlight>
<p><directive module="mod_include">XBitHack</directive>
different log file.</p>
<highlight language="config">
- SetEnvIf Accept-Language "en" english<br />
- CustomLog logs/english_log common env=english<br />
- CustomLog logs/non_english_log common env=!english
+SetEnvIf Accept-Language "en" english
+CustomLog logs/english_log common env=english
+CustomLog logs/non_english_log common env=!english
</highlight>
<p>In a caching scenario one would want to know about
is set):</p>
<highlight language="config">
- Options +Includes
+Options +Includes
</highlight>
<p>For backwards compatibility, the <code>server-parsed</code>
looks for to mark the end of an include element.</p>
<highlight language="config">
- SSIEndTag "%>"
+SSIEndTag "%>"
</highlight>
</usage>
displays when a variable is not set and "echoed".</p>
<highlight language="config">
- SSIUndefinedEcho "<!-- undef -->"
+SSIUndefinedEcho "<!-- undef -->"
</highlight>
</usage>
</directivesynopsis>
errmsg=<var>message</var> --></code> element.</p>
<highlight language="config">
- SSIErrorMsg "<!-- Error -->"
+SSIErrorMsg "<!-- Error -->"
</highlight>
</usage>
</directivesynopsis>
different times).</p>
<highlight language="config">
- SSIStartTag "<%"<br />
- SSIEndTag "%>"
+SSIStartTag "<%"
+SSIEndTag "%>"
</highlight>
<p>The example given above, which also specifies a matching
timefmt=<var>formatstring</var> --></code> element.</p>
<highlight language="config">
- SSITimeFormat "%R, %B %d, %Y"
+SSITimeFormat "%R, %B %d, %Y"
</highlight>
<p>The above directive would cause times to be displayed in the
<section id="logging"><title>Logging Functions</title>
<highlight language="lua">
- -- examples of logging messages<br />
- r:trace1("This is a trace log message") -- trace1 through trace8 can be used <br />
- r:debug("This is a debug log message")<br />
- r:info("This is an info log message")<br />
- r:notice("This is a notice log message")<br />
- r:warn("This is a warn log message")<br />
- r:err("This is an err log message")<br />
- r:alert("This is an alert log message")<br />
- r:crit("This is a crit log message")<br />
- r:emerg("This is an emerg log message")<br />
+-- examples of logging messages
+r:trace1("This is a trace log message") -- trace1 through trace8 can be used
+r:debug("This is a debug log message")
+r:info("This is an info log message")
+r:notice("This is a notice log message")
+r:warn("This is a warn log message")
+r:err("This is an err log message")
+r:alert("This is an alert log message")
+r:crit("This is a crit log message")
+r:emerg("This is an emerg log message")
</highlight>
</section>
<example><title>Example</title>
<highlight language="config">
- LogLevel alert rewrite:trace3
- </highlight>
+LogLevel alert rewrite:trace3
+ </highlight>
</example>
<note><title>RewriteLog</title>
</li>
- <li>
+ <li>
<p>If the <em>TestString</em> has the special value <code>expr</code>, the
<em>CondPattern</em> will be treated as an
<a href="../expr.html">ap_expr</a>.</p>
</p>
<highlight language="config">
-RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"<br />
+RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
RewriteRule "^/images" "-" [F]
</highlight>
</li>