关联数据(RDF)内容与Apache协商 [英] Linked Data (RDF) Content Negotiation with apache

查看:157
本文介绍了关联数据(RDF)内容与Apache协商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有人能为我提供了典型的规则,服务于相应的文件时,被请求的资源,相对于所需的内容类型。更具体地讲,这里是我的情况:

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:

我有我重定向到一个URL我的Apache服务器上的金银丝URL。我想资源URL要像了资源的通用网址,然后根据服务的内容键入相应的文档:RDF,TTL或HTML。

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.

因此​​,我想知道如何做到这一点的.htaccess文件中。任何人都可以在这里帮助?

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

非常感谢

推荐答案

好吧,这里是我做的。

Alright, here is what i did.

我主持我的免费托管网站,该网站允许.htacess文件操作的词汇。

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

在这个文件我按照 http://www.essepuntato.it/lode <的指示写了一些规则/ A>,它的方式如下 HTTP的指示://www.w3。组织/ TR / SWBP - 翻译 - 酒吧/ 。我只是想的东西产生我在飞行中的HTML。

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.

下面是我的.htaccess文件的内容:

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]

不过我有间接的另一个层面,因为我用金银丝地址,因为它可以本体(本体ID)中可以看出

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

下面是金银丝重定向:

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

我不知道这是否是正确的完整,但它的作品。随着浏览器我得到的飞行,并用适当的休息或客户端的wget我得到的XML + RDF生成的HTML

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

这篇关于关联数据(RDF)内容与Apache协商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆