Ivan’s private site

April 27, 2008

Setting up and RDFa file with Apache (second)

Filed under: Code,Semantic Web,Work Related — Ivan Herman @ 0:58
Tags: , ,

A few weeks ago I wrote a short post on how I set up an RDFa file with apache. As commented there by masaka (and I also received some private comments), that setup had the disadvantage that if a client had an accept header that referred both to HTML and to RDF, then it went wrong. Essentially, the server picked whichever was first in the .htaccess file.

So I had to revise (and ask advise from those who understand how Apache works). Here is how SW-FAQ is now set up. It is a little bit more complicated and requires the “.var” facilities to be switched on in Apache. In the same directory where I store the SW-FAQ.html file, I also store a SW-FAQ.var file (called a “type map file”). It looks as follows:

URI: SW-FAQ

URI: SW-FAQ.html
Content-Type: text/html

URI: SW-FAQ.rdf
Content-Type: application/rdf+xml; qs=0.5

the .htaccess file in the same directory is now simpler; it just says:

RewriteEngine On
RewriteBase /2001/sw/
RewriteRule SW-FAQ.rdf /2007/08/pyRdfa/extract?uri=http://www.w3.org/2001/sw/SW-FAQ.html [L]

The .var file switches in Apache’s content negotiation mechanism. The media type determines which version is returned, and this takes into account the “quality” parameter of the HTTP accept header, too. The .htaccess file would then just direct the server to run the RDFa distiller and return the result when RDF is required. This seems to work better…

(It was TimBL who pushed me to do the changes this time, and the basic structure comes from him, actually…)

Advertisements

Blog at WordPress.com.

%d bloggers like this: