Module mod_xhtml_neg

This module is contained in the mod_xhtml_neg.c file. It provides content negotiation facilities for XHTML documents.

Summary

This module provides content negotiation facilities for XHTML documents that conform to Appendix C compatibility requirements of the XHTML 1.0 specification. This allows compatible browsers to view XHTML content as XML-compliant documents, and older or less compatible clients to view XHTML content as text/html documents.

Directives


XhtmlNegActive

Syntax: XhtmlNegActive on|off
Context: server config, virtual host, directory, .htaccess
Status: Extension
Module: mod_xhtml_neg
Compatibility: Apache 1.3 and above

This directive enables or disables content negotiation for the document realm in question. (That is, if found in an .htaccess file, for instance, it applies only to documents generated from that directory.) If set to Off, no negotiation will be performed for any document in the realm (unless overridden at a lower level, such as an .htaccess file overriding a server config file). If set to On, the header will be added to served documents according to the criteria defined by the XhtmlNegTypes and XhtmlNegStarsIgnore directives.

Note that this directive does not guarantee that content negotiation will be performed. If the criteria aren't met, no negotiation will be performed, and the effect will be as though this directive wasn't even specified.

XhtmlNegLog

Syntax: XhtmlNegLog /path/to/log/file
Context: server config
Status: Extension
Module: mod_xhtml_neg
Compatibility: Apache 1.3 and above

The XhtmlNegLog directive defines the path and filename of an optional log file. Status messages regarding success or failure to negotiate are sent to this log file. If this directive is not specified, no logging takes place. For example:

    XhtmlNegLog /var/log/apache/mod_xhtml_neg.log

XhtmlNegTypes

Syntax: XhtmlNegTypes file-extension content-type1 content-type2...
Context: server config, virtual host, directory, .htaccess
Status: Extension
Module: mod_xhtml_neg
Compatibility: Apache 1.3 and above

The XhtmlNegTypes directive defines the content-negotiation for a given file extension. Each token contains a content-type, followed by optional charset value, relative quality, and profile information. For example:

    XhtmlNegTypes .html application/xhtml+xml;charset=iso-8859-1 \
	  application/xml;q=0.5 text/html;charset=iso-8859-1;q=0.8 \
	  text/xml;charset=iso-8859-1;q=0.2

This tells us that the content-type application/xhtml+xml is preferred, followed by text/html, application/xml, and finally text/xml.

If no match is found using content-negotiation, the default content type is used.

Note that setting the AddDefaultCharset directive for the Apache core is recommended regardless of whether the "charset" parameter is specified.

XhtmlNegStarsIgnore

Syntax: XhtmlNegStarsIgnore [0 - 3]
Context: server config, virtual host, directory, .htaccess
Status: Extension
Module: mod_xhtml_neg
Compatibility: Apache 1.3 and above

The XhtmlNegStarsIgnore directive indicates the number of stars ("*") in an Accept token that should be ignored when performing content-negotiation. This is used to get around bugs in certain user agents that send Accept headers of "*/*" in every request without assigning them a lower quality value.

For example:

    XhtmlNegStarsIgnore 2

Here, Accept headers such as "text/html" or "text/*" will be considered when performing content-negotiation, but "*/*" will be ignored.

Setting XhtmlNegStarsIgnore 0 is effectively the same as disabling content-negotiation altogether. XhtmlNegStarsIgnore 3 allows all Accept headers to be used for content-negotiation.

XhtmlNegCache

Syntax: XhtmlNegCache on|off
Context: server config
Status: Extension
Module: mod_xhtml_neg
Compatibility: Apache 1.3 and above

The XhtmlNegCache directive controls caching of negotiated content when the request is sent using HTTP 1.0. By default, caching is disabled due to problems with HTTP 1.0 proxies being unable to reliably give user agents the correct content-type.

For HTTP 1.1 (and later) this directive has no effect, since HTTP 1.1 gives proxies the information they need in order to send correctly negotiated content to user-agents.


Back home.