altera o tipo de mime para um agente do usuário

1

Estou tentando substituir o tipo mime de um arquivo apenas para um agente do usuário específico (Chrome) e deixar o padrão para os outros (Firefox).

Options +Indexes
IndexOptions -FancyIndexing
Header set Access-Control-Allow-Origin "*"


RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.org$
RewriteRule ^(.*)$ http://example.org/$1 [R=301,L]


# Turn off MultiViews
Options -MultiViews

# Directive to ensure *.rdf files served as appropriate content type,
# if not present in main apache config
AddType "application/rdf+xml" .rdf
AddType "text/turtle" .ttl

# Rewrite engine setup
RewriteBase /

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^$ index.rdf [R=303]

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} text/turtle
RewriteRule ^$ index.ttl [R=303]

# firefox display xml by default but downloads turtle
RewriteCond %{HTTP_USER_AGENT} Firefox/.*
RewriteRule ^$ index.rdf [R=303]

# make chrome display xml file with faking MIME type to application/xml instead application/rdf+xml
RewriteCond %{HTTP_USER_AGENT} ^.*Chrome/.*$
RewriteCond %{REQUEST_URI} ^/index.rdf$
RewriteRule ^index.rdf - [T=application/xml]

# Choose the default response (turtle for chrome safari ...which display turtle as raw text)
# Serve RDF/XML by default
RewriteRule ^$ index.ttl [R=303]

A razão para isso é que o mimetype application/xml é exibido inline no chrome, mas application/rdf+xml é baixado. Gostaria de deixar o valor em application/rdf+xml e só alterá-lo para o cromo. Mas com a minha configuração, o firefox também recebe o tipo de mime errado.

    
por koma5 28.07.2017 / 16:17

0 respostas