Github ページで一連のファイル(RDF/XML、Turtle、JSON-LD などの異なるシリアル化形式を持つ同じ RDF コンテンツ) をホストし、w3id URLを永続的な識別子として使用するというユース ケースがあります。
さらに、そのパーマネント URL でコンテンツ ネゴシエーションを行いたいと考えています。ファイルを Apache サーバーでホストしている場合、これは些細なことですが、残念ながら Github ページはコンテンツ ネゴシエーションをサポートしていません。そこで、URL 書き換えルールでどこまでできるか試しています。
したがって、考え方は次のようになります。
GET http://w3id.org/foo -- redirect to --> http://foo.git.io/content.ttl
Accept: text/turtle
GET http://w3id.org/foo -- redirect to --> http://foo.git.io/content.jsonld
Accept: application/ld+json
現在、私のルールは次のようになっています。
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_ACCEPT} ^.*application/rdf\+xml.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.rdf [R=303,L]
RewriteCond %{HTTP_ACCEPT} ^.*text/turtle.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.ttl [R=303,L]
RewriteCond %{HTTP_ACCEPT} ^.*application/ld\+json.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.jsonld [R=303,L]
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.html [R=303,L]
これは大部分のケースで機能しますが、いくつかのまれなケースでは機能しません。たとえば、次のような受け入れヘッダーがある場合
Accept: application/rdf+xml;q=0.9,text/turtle
これは application/rdf+xml を返します (最初のルールが一致するため) が、コンテンツ ネゴシエーションによれば turtle を返す必要があります。このコーナーケースを処理するルールを改善する方法を知っている人はいますか?