As I said yesterday, the SW FAQ file is now in XHTML/RDFa. However, I was wondering how to set up the environment so that the right URI-s would lead to the right format, ie, either HTML or RDF. Of course, one could generate the SW-FAQ.rdf file offline and put that on the server, but that sounded a little bit like cheating (although, I must admit, that is what I did first). What one would like is
http://www.w3.org/2001/sw/SW-FAQshould return- XHTML by default
- RDF/XML if so requested, but generated from the XHTML file on-the-fly via an RDFa processor; and to that with an HTTP 303 round (to make it really neat)
http://www.w3.org/2001/sw/SW-FAQ.rdfshould return RDF/XML, again generated on-the-flyhttp://www.w3.org/2001/sw/SW-FAQ.htmlshould return, well, XHTML
It so happens that, on apache, a little bit of .htaccess wizardry works. The problem is that you have to be the wizard, which I am not. Luckily, my colleague and friend Ralph Swick is
. So here is the .htaccess file:
RewriteEngine On
RewriteBase /2001/sw/
#This is where the RDFa distiller is called on-the-fly:
RewriteRule SW-FAQ.rdf /2007/08/pyRdfa/extract?uri=http://www.w3.org/2001/sw/SW-FAQ.html [L]
# Take care of the RDF case when so requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^SW-FAQ$ SW-FAQ.rdf [R=303,L]
RewriteRule ^SW-FAQ$ SW-FAQ.html [L]
And voilà! Thanks Ralph…
