Allow Encoded Slashes
As specified in the Image API, slashes (“/
”, “\
”) in the identifer portion of the base uri MUST be encoded. This may cause problems with some HTTP servers. Apache servers from version 2.2.18 support the AllowEncodedSlashes NoDecode
configuration directive which will correctly pass these characters to client applications without rejecting or decoding them.
AllowEncodedSlashes On
Servers using older versions of Apache and local identifiers which include these characters will need to use a workaround such as internally translating or escaping slash and backslash to safe value (perhaps by double URI-encoding them).
Enabling CORS
Both specifications prefer to have cross-origin resource sharing enabled. This may be enabled with the following configuration snippet:
LoadModule headers_module modules/mod_headers.so
Header set Access-Control-Allow-Origin "*"
Set Compliance Link Header
The Image API states that a server may indicate its compliance level in a link header. This can be done as follows:
Header set Link '<http://iiif.io/api/image/2/level1.json>;rel="profile"'
Conditional Content Types
Both the Image and Presentation APIs state that clients may request JSON-LD, as opposed to plain JSON.
In the Image API, this may be enabled with the following configuration snippet (note that this assumes the compliance level Link header has been set as above):
<FilesMatch "\.json">
SetEnvIf Accept "application/ld\+json" WANTS_jsonld
Header set Content-Type "application/ld+json" env=WANTS_jsonld
Header append Link '<http://iiif.io/api/image/2/context.json>;rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json"' env=!WANTS_jsonld
</FilesMatch>
The above configuration snippet may also be used for Presentation API implementations that have URIs ending in .json
, but the line starting Header append Link
should be deleted and it will not work for the recommended URI pattern. The following snippet will work for the recommended patterns:
<LocationMatch "^/prefix/(collection/.*|.*/manifest|.*/(sequence|canvas|annotation|list|range|layer)/.*)$">
SetEnvIf Accept "application/ld\+json" WANTS_jsonld
Header set Content-Type "application/json"
Header set Content-Type "application/ld+json" env=WANTS_jsonld
</LocationMatch>
Note that for version 3.0 of the Presentation and Image APIs, these media types should also have the appropriate profile
parameter as part of the Content-Type
value.