Ivan’s private site

February 22, 2008

Setting up an RDFa file with apache

Filed under: Semantic Web,Work Related — Ivan Herman @ 17:56

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

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…



  1. Hi, con neg is generally good, but I’m afraid this makes XHTML content hard to use for some UAs, e.g. Firefox + Tabulator addon (that accepts application/rdf+xml)

    Comment by masaka — February 23, 2008 @ 4:41

  2. Masaka,

    I am not sure I understand. The setup is such that if a client uses the URI …/SW-FAQ, and sets application/rdf+xml in the accept header, then the RDF is returned. I would think that this is what these UAs do…

    (I may miss something)

    Comment by Ivan Herman — February 25, 2008 @ 15:27

  3. […] a simple solution that solves the RDF publishing dilemma. You can read about the details in Ivan’s post. The basic idea is that Web publishers will use RDFa to describe semantic information in an HTML […]

    Pingback by Geospatial Semantic Web Blog - GIS Data Integration, Geo Ontology, Geo Tagging & Geo Web 2.0 News » Blog Archive » A solution to the RDF publishing dilemma — February 25, 2008 @ 16:26

  4. Ivan,

    Firefox+Tabulator (FF+Tab) will accept application/rdf+xml, but q=0.93, i.e. it prefers XHTML to RDF when the former variant available. From SW-FAQ, however, FF+Tab receives RDF version (it’s fun, though ;-), and I cannot read XHTML content.

    Probably, this content negotiation will better serve if it takes account of q parameter in accept header.


    Comment by masaka — February 26, 2008 @ 2:27

  5. And it works really well (ignore the last test, Vapour purpose is other).

    Comment by Sergio Fernandez — February 26, 2008 @ 12:37

  6. […] extracted RDF one, depending on the Accept header, combining some rewrite rules that Ivan Herman defined for the SW Faq and the .htaccess used for the Flickr wrapper. My old foaf.rdf file is also now […]

    Pingback by RDFa profile and new URI : Alexandre Passant — March 11, 2008 @ 21:01

RSS feed for comments on this post.

Create a free website or blog at WordPress.com.

%d bloggers like this: