1

I was wondering if someone could provide me with the typical rule, to serve the appropriate file when a resource is requested, with respect to the content type required. To be more specific here is my situation:

I have a purl URL that i redirect to an URL on my apache server. I would like to resource URL to be like a generic URL for the resource, and then serve the appropriate doc depending on the content Type: RDF, TTL, or HTML.

Hence i would like to know how to do that within the .htaccess file. Can anyone help here ?

Many thanks

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
  • 1
    Have you seen [Best Practice Recipes for Publishing RDF Vocabularies, W3C Working Group Note 28 August 2008](http://www.w3.org/TR/swbp-vocab-pub/)? The introduction says, "This document describes best practice recipes for publishing vocabularies or ontologies on the Web (in RDF Schema or OWL). The features of each recipe are described in detail, so that vocabulary designers may choose the recipe best suited to their needs. Each recipe introduces general principles and an example configuration for use with an Apache HTTP server (which may be adapted to other environments)." – Joshua Taylor May 06 '14 at 15:28
  • 2
    Particularly, there's a [Content negotiation](http://www.w3.org/TR/swbp-vocab-pub/#negotiation) section. – Joshua Taylor May 06 '14 at 15:28
  • Yes true indeed. I saw it before but not good enough to see that my special case was dealt with. thanks for redirecting (302) me on it ;) – MaatDeamon May 06 '14 at 16:17
  • 1
    duplicated at http://answers.semanticweb.com/questions/28043/linked-data-rdf-content-negotiation-with-apache – Joshua Taylor May 06 '14 at 16:40
  • If you found a solution for this, you should write it up as an answer and mark it as accepted for the benefit of others with the same needs. – Joshua Taylor May 09 '14 at 21:18
  • yes, i will, i have yet to implement it, in he coming days, and i will post it – MaatDeamon May 09 '14 at 21:35
  • Great; I look forward to it! – Joshua Taylor May 09 '14 at 21:35

1 Answers1

0

Alright, here is what i did.

I'm hosting my vocabulary on a free hosting website which allows for the manipulation of the .htacess file.

On that file i wrote some rules according to the instructions of http://www.essepuntato.it/lode, which by the way follows the instructions of http://www.w3.org/TR/swbp-vocab-pub/. I just wanted something to generate my HTML on the fly.

Here is my .htaccess file content:

# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /

# Rewrite engine setup<br/> 
RewriteEngine On


AddType application/rdf+xml .owl

AddType application/rdf+xml .rdf .owl

AddType text/turtle .ttl

# Rewrite rule to serve HTML content<br/>

RewriteCond %{HTTP_ACCEPT} !application/rdf\+xml.*(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
RewriteRule ^CommitmentOntology$ http://www.essepuntato.it/lode/http://theoceanopeninteractioninfrastructure.webege.com/CommitmentOntology [R=303,L]

# Rewrite rule to serve RDF/XML content if requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^CommitmentOntology$ CommitmentOntology.owl [R=303]

# Choose the default response
RewriteRule ^CommitmentOntology$ CommitmentOntology.owl [R=303]

However i have another level of indirection because i use purl address as it can be seen within the ontology (Ontology ID)

Here is the redirection on Purl:

id: /net/OceanOIS-Commitments 
type: 303
seealso: http://theoceanopeninteractioninfrastructure.webege.com/CommitmentOntology
maintainers: Maatari

I don't know if it is fully right but it works. With the browser i get the HTML generated on the fly and with a proper rest client or wget i get the xml+rdf

MaatDeamon
  • 9,532
  • 9
  • 60
  • 127