我试图只覆盖特定用户代理的文件的MIMEtypes(Chrome),并保留其他(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]
原因是mimetype application/xml
在chrome中内联显示,但application/rdf+xml
被下载。 我想离开它在application/rdf+xml
,只改变它的铬。 但是用我的configurationFirefox也得到了错误的mimetype。