Search code examples
apachemod-rewritehttp-headersjson-ldresponse-headers

When my server receives a request with the header "Accept: application/ld+json", return a specific file


I want to be able to do the following:

When my Apache server receives a request with the header:

Accept: application/ld+json

I want to return the file "./jsonld", with the header

ContentType: application/ld+json

This is what I have so far :

<If "%{HTTP:Accept} =~ m#application/ld\+json#">
   RewriteEngine On
   RewriteRule ^ /jsonld [L]

   Header always set Content-Type "application/ld+json"

</If>

Solution

  • AddType application/ld\+json .jsonld
    
    RewriteEngine On 
    RewriteCond %{HTTP:Accept} application/ld\+json
    RewriteRule ^ jsonld.jsonld