htaccess redirects for text/turtle etc
stain opened this issue · comments
Stian Soiland-Reyes commented
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]
Stian Soiland-Reyes commented
Obviously would also need to test for recursion depending on how rdf.greggkellogg requests /ops - perhaps use index.html instead as 'uri='?