Skip to content

Commit

Permalink
Merge pull request perma-id#1694 from thesmartenergy/master
Browse files Browse the repository at this point in the history
updated BOT for more mediatypes
  • Loading branch information
dgarijo authored Apr 7, 2020
2 parents 6410a94 + 2ff2bbd commit a874e25
Showing 1 changed file with 23 additions and 64 deletions.
87 changes: 23 additions & 64 deletions bot/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,39 @@ Options -MultiViews
AddType application/rdf+xml .rdf
AddType application/rdf+xml .owl
AddType text/turtle .ttl
AddType application/n-triples .n3
AddType text/n3 .n3
AddType application/n-triples .nt
AddType application/ld+json .json

### internal redirection for home page

### Rewrite rules for latest version
# Rewrite rule to serve HTML content from the vocabulary URI if requested
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 ^$ https://w3c-lbd-cg.github.io/bot [R=303,L]
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml|text/turtle|text/n3|application/n-triples|application/ld+json
RewriteRule ^/?$ bot

# Rewrite rule to serve TTL content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} ^.*text/turtle.* [OR]
RewriteCond %{HTTP_ACCEPT} text/\* [OR]
RewriteCond %{HTTP_ACCEPT} \*/turtle
RewriteRule ^$ https://w3c-lbd-cg.github.io/bot/bot.ttl [R=303,L]
RewriteCond %{HTTP_ACCEPT} !(application/rdf\+xml|text/turtle|text/n3|application/n-triples|application/ld+json)
RewriteRule ^/?$ index.html

# If suffix ttl, redirect to turtle version
RewriteRule ^bot.ttl$ https://w3c-lbd-cg.github.io/bot/bot.ttl [R=303,L]
### internal redirection to append extension for content negotiation

# If suffix html, redirect to html version
RewriteRule ^bot.html$ https://w3c-lbd-cg.github.io/bot [R=303,L]
# redirects .*/abcd to .*/abcd.html
RewriteCond %{HTTP_ACCEPT} !(application/rdf\+xml|text/turtle|text/n3|application/n-triples|application/ld+json)
RewriteRule ^(.*/)?([^\./]*)$ $1$2.html [L]

RewriteCond %{HTTP_ACCEPT} text/turtle
RewriteRule ^(.*/)?([^\./]*)$ $1$2.ttl [L]

### Rewrite rules for other serialisation (if they get converted)
## Rewrite rule to serve JSON-LD content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} application/ld\+json
#RewriteRule ^$ https://w3c-lbd-cg.github.io/bot/bot.jsonld [R=303,L]
RewriteCond %{HTTP_ACCEPT} application/ld+json
RewriteRule ^(.*/)?([^\./]*)$ $1$2.jsonld [L]

## Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} \*/\* [OR]
#RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
#RewriteRule ^$ https://w3c-lbd-cg.github.io/bot/bot.rdf [R=303,L]
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^(.*/)?([^\./]*)$ $1$2.rdf [L]

## Rewrite rule to serve N-Triples content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} application/n-triples
#RewriteRule ^$ https://w3c-lbd-cg.github.io/bot/bot.nt [R=303,L]
RewriteCond %{HTTP_ACCEPT} text/n3
RewriteRule ^(.*/)?([^\./]*)$ $1$2.n3 [L]

RewriteCond %{HTTP_ACCEPT} text/n-triples
RewriteRule ^(.*/)?([^\./]*)$ $1$2.nt [L]

## If suffix rdf, redirect to rdf version
#RewriteRule ^bot.rdf$ https://w3c-lbd-cg.github.io/bot/bot.rdf [R=303,L]
### external redirections

## If suffix jsonld, redirect to jsonld version
#RewriteRule ^bot.jsonld$ https://w3c-lbd-cg.github.io/bot/bot.jsonld [R=303,L]

## If suffix nt, redirect to nt version
#RewriteRule ^bot.nt$ https://w3c-lbd-cg.github.io/bot/bot.nt [R=303,L]

# Rewrite rules for any other version.
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 ^(.+)$ https://w3c-lbd-cg.github.io/bot/$1 [R=302,NE,L]

# Rewrite rule to serve JSON-LD content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} application/ld\+json
#RewriteRule ^(.+)$ https://w3c-lbd-cg.github.io/bot/$1/bot.json [R=302,NE,L]

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} \*/\* [OR]
#RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
#RewriteRule ^(.+)$ https://w3c-lbd-cg.github.io/bot/$1/bot.rdf [R=302,NE,L]

# Rewrite rule to serve N-Triples content from the vocabulary URI if requested
#RewriteCond %{HTTP_ACCEPT} application/n-triples
#RewriteRule ^(.+)$ https://w3c-lbd-cg.github.io/bot/$1/bot.nt [R=302,NE,L]

# Rewrite rule to serve TTL content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} text/turtle [OR]
RewriteCond %{HTTP_ACCEPT} text/\* [OR]
RewriteCond %{HTTP_ACCEPT} \*/turtle
RewriteRule ^(.+)$ https://w3c-lbd-cg.github.io/bot/$1/bot.ttl [R=302,NE,L]

### Default response
RewriteRule ^$ https://w3c-lbd-cg.github.io/bot [R=303,L]
RewriteRule ^(.*)$ https://w3c-lbd-cg.github.io/bot/$1 [R=302,L]

0 comments on commit a874e25

Please sign in to comment.