bridgedb / vocabularies

Source files for the BridgeDb ontology
0 stars 2 forks source link

htaccess redirects for text/turtle etc #3

Open stain opened 8 years ago

stain commented 8 years ago

I found that

http://rdf.greggkellogg.net/distiller

worked much better than pyRDFa, which fails for RDF/XML output.

something like (untested)

# Rewrite engine setup
RewriteEngine On

# Rewrite rule to serve HTML content
RewriteCond %{HTTP_ACCEPT} !(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} text/turtle [OR]
RewriteCond %{HTTP_ACCEPT} application/x-turtle [OR]
RewriteCond %{HTTP_ACCEPT} text/rdf+n3
RewriteRule ^ops$  http://rdf.greggkellogg.net/distiller?format=turtle&in_fmt=rdfa&uri=http://vocabularies.bridgedb.org/ops# [R=303,L]

# Rewrite rule to serve RDF/XML content if requested
RewriteCond %{HTTP_ACCEPT} !(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^ops$  http://rdf.greggkellogg.net/distiller?format=rdfxml&in_fmt=rdfa&uri=http://vocabularies.bridgedb.org/ops# [R=303,L]

RewriteCond %{HTTP_ACCEPT} !(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} application/ld+json [OR]
RewriteCond %{HTTP_ACCEPT} application/json
RewriteRule ^ops$  http://rdf.greggkellogg.net/distiller?format=jsonld&in_fmt=rdfa&uri=http://vocabularies.bridgedb.org/ops# [R=303,L]

RewriteCond %{HTTP_ACCEPT} application/n-triples
RewriteRule ^ops$  http://rdf.greggkellogg.net/distiller?format=ntriples&in_fmt=rdfa&uri=http://vocabularies.bridgedb.org/ops# [R=303,L]

# Choose the default response (as before)
RewriteRule ^ops$ index.html [L]
stain commented 8 years ago

Obviously would also need to test for recursion depending on how rdf.greggkellogg requests /ops - perhaps use index.html instead as 'uri='?