Recipe 8.10 Including a Standard Header


You want to include a header (or footer) in each of your HTML documents.


Use SSI by inserting a line in all your parsed files:

<--#include virtual="/include/headers.html" -->


By using the SSI include directive, you can have a single header file that can be used throughout your web site. When your header needs to be modified, you can make this change in one place and have it go into effect immediately across your whole site.

The argument to the virtual attribute is a local URI and subject to all normal Alias, ScriptAlias, RewriteRule, and other commands, which means that:

<--#include virtual="/index.html" -->

will include the file from your DocumentRoot, and:

<--#include virtual="/cgi-bin/foo" -->

will include the output from the foo script in your server's ScriptAlias directory.

If the argument doesn't begin with a / character, it's treated as being relative to the location of the document using the #include directive.

Be aware that URIs passed to #include virtual may not begin with ../, nor may they refer to full URLs such as Documents included using relative syntax (i.e., those not beginning with /) may only be in the same location as the including file, or in some sublocation underneath it. Server processing of the URI may result in the actual included document being located somewhere else, but the restrictions on the #include virtual SSI command syntax permit only same-location or descendent-location URIs.

See Also

  • Recipe 8.7

  • Recipe 8.8

Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: