Configuring Apache HTTP Server for RDFS/OWL Ontologies: Requirements and Examples

This is a writeup of possible configurations for HTTP servers (using Apache 2.0.46 as the example), to support the use of HTTP URIs for identifying classes, properties and individuals in RDFS/OWL ontologies.

$Id: index.html,v 1.10 2005/11/01 16:08:38 ajm65 Exp $

@@TODO get these checked by HTTP and Apache experts

Contents

Minimum Requirements

For each HTTP URI denoting an RDFS/OWL class, property or individual ...

  1. ... it is possible for an HTTP client to obtain an RDF/XML serialisation of a set of RDF statements constituting the definitive RDF description of that class, property or individual, via one or more HTTP GET requests which include the header field 'Accept: application/rdf+xml'.
  2. ... it is not possible to receive a response to an HTTP request that is not consistent with TAG resolution on httpRange-14 [@@TODO ref].
  3. ... it is not possible to obtain responses to HTTP requests that lead to ambiguity, uncertainty, or inconsistency in the interpretation of the nature of the denoted resource.

Good-Practice Requirements

These requirements are an extension of the minimum requirements.

For each HTTP URI denoting an RDFS/OWL class, property or individual ...

  1. ... it is possible for an HTTP client to obtain the most relevant item of human-readable HTML content documentation for that class, property or individual, via one or more HTTP GET requests that include an 'Accept:' header field with the appropriate HTML content type(s).
  2. ... it is possible for an RDF application to differentiate between versions of the definitive RDF description of that class, property or individual, by using as provenance information the ultimate endpoint of an attempt to dereference the URI via an HTTP GET request with the header field 'Accept: application/rdf+xml'.

A Note on Apache Configuration

These examples assume you don't have access to the main apache configuration files, so all examples here use directives placed inside .htaccess files. All examples have been tested for Apache 2.0.46.

A Note on 'Hash vs. Slash'

The use of both 'hash' and 'slash' HTTP URIs to denote RDFS/OWL classes, properties or individuals is potentially consistentent with the TAG resolution on httpRange-14 [@@TODO ref]. However, the practicalities of configuring an HTTP server to meet the minimum and good-practice requirements differ for hash and slash namespaces, therefore these are treated under different headings below.

Hash ('#') Namespaces

'Hash URIs' are e.g.:

http://www.example.com/foo#bar
http://www.example.com/foo/bar#baz

N.B. the fragment identifier (i.e. the bit after the '#') is not passed to the server in an HTTP request, this is mandated by the HTTP 1.1 specification (@@TODO ref).

Example 1: Hash Static Configuration, Minimal

For ontology ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example1

... defining classes ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example1#classA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example1#classB

... and properties ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example1#propA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example1#propB

...

  1. Create a file called 'example1.rdf' that contains an RDF/XML serialisation of the RDF description of all classes and properties defined by example 1 ontology.
  2. Copy 'example1.rdf' to the directory /documentroot/VM/http-examples/ on the server.
  3. Add the following directives to the .htaccess file in the /documentroot/VM/http-examples/ directory ...
# Directive to ensure *.rdf files served as appropriate content type, 
# if not present in main apache config ...
AddType application/rdf+xml .rdf

# Rewrite engine setup ...
RewriteEngine On
RewriteBase /VM/http-examples

# Rewrite rule to make sure we serve the RDF/XML content from the namespace URI ... 
RewriteRule ^example1$ example1.rdf

Notes

This setup ensures all HTTP GET requests return an RDF/XML serialisation, thereby meeting minimum requirements.

Example 2: Hash Static Configuration, Best Practice

For ontology ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example2

... defining classes ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example2#classA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example2#classB

... and properties ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example2#propA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example2#propB

...

  1. Create a file called '2005-10-31.rdf' that contains an RDF/XML serialisation of the RDF description of all classes and properties defined by example 2 ontology as at 2005-10-31 (or whatever is current date).
  2. Copy '2005-10-31.rdf' to the directory /documentroot/VM/http-examples/example2/rdf/ on the server.
  3. Create a file called '2005-10-31.html' that contains HTML content documentation about all classes and properties defined by example 2 ontology as at 2005-10-31 (or whatever is current date). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the fragment identifier of the documented class/property.
  4. Copy '2005-10-31.html' to the directory /documentroot/VM/http-examples/example2/html/ on the server.
  5. Add the following directives to the .htaccess file in the /documentroot/VM/http-examples/ directory ...

    # Directive to ensure *.rdf files served as appropriate content type, 
    # if not present in main apache config ...
    AddType application/rdf+xml .rdf
    
    # Rewrite engine setup ...
    RewriteEngine On
    RewriteBase /VM/http-examples
    
    # Rewrite rule to make sure we serve HTML content from the namespace URI if requested ... 
    RewriteCond %{HTTP_ACCEPT} text/html [OR]
    RewriteCond %{HTTP_ACCEPT} text/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xhtml+xml
    RewriteRule ^example2$ example2/html/2005-10-31 [R=303]
    
    # Rewrite rule to make sure we serve the RDF/XML content from the namespace URI by default ... 
    RewriteRule ^example2$ example2/rdf/2005-10-31 [R=303]

  6. Make sure that the 'MultiViews' option is enabled for both the directories /documentroot/VM/http-examples/example2/html/ and /documentroot/VM/http-examples/example2/rdf/ .

Notes

This setup means all URIs are 'clickable'. I.e. clicking on a link with a class or prop URI as the target takes you (via a redirect) to the most appropriate bit of documentation, which is part of a larger document. This is ideal for small to medium size vocabs.

This setup also means clients asking for 'application/rdf+xml' end up at a snapshot, and can use provenance to differentiate between conflicting descriptions as the ontology evolves.

N.B. because the frag id never gets to the server, we can't serve smaller chunks of html or rdf.

Slash ('/') Namespaces

'Slash URIs' are e.g.:

http://www.example.com/foo/bar
http://www.example.com/foo/bar/baz

Example 3: Slash Static Configuration, Minimal

For ontology ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example3/

... defining classes ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example3/classA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example3/classB

... and properties ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example3/propA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example3/propB

...

  1. Create a file called 'index.rdf' that contains an RDF/XML serialisation of the RDF description of all classes and properties defined by example 3 ontology.
  2. Copy 'index.rdf' to the directory /documentroot/VM/http-examples/example3/ on the server.
  3. Add the following directives to the .htaccess file in the /documentroot/VM/http-examples/example3/ directory ...
# Directives to override inherited behaviour
Options -MultiViews -Indexes

# Directive to ensure *.rdf files served as appropriate content type, 
# if not present in main apache config ...
AddType application/rdf+xml .rdf

# Rewrite engine setup ...
RewriteEngine on
RewriteBase /VM/http-examples/example3/

# Rewrite rule to make sure we directly serve the RDF/XML content for the namespace URI ...
RewriteRule ^$ index.rdf [L]

# Rewrite rule to make sure we finish here after internal redirect from the above rule ...
RewriteRule ^index.rdf$ - [L]

# Rewrite rule to make sure we redirect for any other URI ...
RewriteRule ^(.+)$ "/VM/http-examples/example3/" [R=303]

Notes

The second rule is required to catch the internal redirect from the first rule, and prevent us ending in an eternal redirect loop.

This setup means that a request for the ontology URI always returns RDF/XML content, and a request for a class or prop URI always results in a redirect, thereby satisfying minimum requirements.

Example 4: Slash Static Configuration, Best Practice (Single Document)

For ontology ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example4/

... defining classes ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example4/classA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example4/classB

... and properties ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example4/propA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example4/propB

...

  1. Create a file '2005-10-31.rdf' that contains an RDF/XML serialisation of the RDF description of all classes and properties defined by example 4 ontology as at 2005-10-31 (or whatever is current date).
  2. Copy '2005-10-31.rdf' to the directory /documentroot/VM/http-examples/example4-rdf/ on the server.
  3. Create a file called '2005-10-31.html' that contains HTML content documentation about all classes and properties defined by example 4 ontology as at 2005-10-31 (or whatever is current date). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the local name of the documented class/property.
  4. Copy '2005-10-31.html' to the directory /documentroot/VM/http-examples/example4-html/ on the server.
  5. Add the following directives to the .htaccess file in the /documentroot/VM/http-examples/ directory ...
    # Directive to ensure *.rdf files served as appropriate content type, 
    # if not present in main apache config ...
    AddType application/rdf+xml .rdf
    
    # Rewrite engine setup ...
    RewriteEngine On
    RewriteBase /VM/http-examples
    
    # Rewrite rule to make sure we serve HTML content from the namespace URI if requested ... 
    RewriteCond %{HTTP_ACCEPT} text/html [OR]
    RewriteCond %{HTTP_ACCEPT} text/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xhtml+xml
    RewriteRule ^example4/(.*)$ example4-html/2005-10-31#$1 [R=303,NE]
    
    # Rewrite rule to make sure we serve the RDF/XML content from the namespace URI by default ... 
    RewriteRule ^example4/.*$ example4-rdf/2005-10-31 [R=303]
    
    # N.B. for the above to work, the 'example4/' directory must not actually exist in the file system.

  6. Make sure MultiViews is enabled for directories example4-rdf/ and example4-html/ .

Notes

N.B. the 'NE' flag must be added to the first rewrite rule, to prevent escaping of the '#' character after rewriting.

Because this allows all HTML documentation to be packaged into a single file with anchors, this setup is ideal for small to medium sized vocabs.

Example 5: Slash Static Configuration, Best Practice (Multiple Documents)

For ontology ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example5/

... defining classes ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example5/classA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example5/classB

... and properties ...

http://isegserv.itd.rl.ac.uk/VM/http-examples/example5/propA
http://isegserv.itd.rl.ac.uk/VM/http-examples/example5/propB

...

  1. Create a file '2005-10-31.rdf' that contains an RDF/XML serialisation of the RDF description of all classes and properties defined by example 5 ontology as at 2005-10-31 (or whatever is current date).
  2. Copy '2005-10-31.rdf' to the directory /documentroot/VM/http-examples/example5-rdf/ on the server.
  3. Create a file called 'index.html' that contains HTML content documentation about all classes and properties defined by example 4 ontology as at 2005-10-31 (or whatever is current date).
  4. Create files 'classA.html' 'classB.html' 'propA.html' 'propB.html' each of which documents only the class/property with the corresponding name, as at 2005-10-31 (or whatever is current date).
  5. Copy all html files to the directory /documentroot/VM/http-examples/example5-html/2005-10-31/ on the server.
  6. Add the following directives to the .htaccess file in the /documentroot/VM/http-examples/ directory ...

    # Directive to ensure *.rdf files served as appropriate content type, 
    # if not present in main apache config ...
    AddType application/rdf+xml .rdf
    
    # Rewrite engine setup ...
    RewriteEngine On
    RewriteBase /VM/http-examples
    
    # Rewrite rule to make sure we serve HTML content from the namespace URI if requested ... 
    RewriteCond %{HTTP_ACCEPT} text/html [OR]
    RewriteCond %{HTTP_ACCEPT} text/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xml [OR]
    RewriteCond %{HTTP_ACCEPT} application/xhtml+xml
    RewriteRule ^example5/(.*)$ example5-html/2005-10-31/$1 [R=303]
    
    # Rewrite rule to make sure we serve the RDF/XML content from the namespace URI by default ... 
    RewriteRule ^example5/.*$ example5-rdf/2005-10-31 [R=303]
    
    # N.B. for the above to work, the 'example5/' directory must not actually exist in the file system.

  7. Make sure MultiViews is enabled for directories example5-rdf/ and example5-html/2005-10-31/ .

Notes

This setup is better for documenting large vocabs, as it allows documentation to be partitioned into separate files.

Example 6: Slash Dynamic Configuration, Best Practice

@@TODO conditionally rewrite URLs to go to HTML generating service for HTML requests, and to SPARQL service with DESCRIBE or CONSTRUCT queries for RDF requests ...