Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
This page explains how MIME types (media types, content types) are mapped to file extensions in Magnolia.
MIME types are configured in
config:/server/MIMEMapping. You can edit them with the Configuration app.
Example: The MIME type
text/html is mapped to extension
html. The type
The example above shows just two types. Magnolia configures many more MIME types by default.
Parent node name such as
MIME type for the given file extension. See Official list of media types.
File extension. If not set,
ContentTypeFilter is a filter in the Magnolia filter chain.
ContentTypeFilter does not set the response content type, instead it's the responsibility of renderers/servlets to set correct content type (for instance FreemarkerRenderer sets the content type). However, ContentTypeFilter sets some parameters onto AggregationState and takes care of restricting responses to configured MIME types and matching requests to content types.
Restricting responses to configured MIME types
By default, Magnolia tries to respond to every request, even if the MIME type is not configured. To restrict responses to configured MIME types only, add a
registeredExtensionsOnly property to the
contentType filter configuration:
true Magnolia will respond with response code 400 to requests with extensions that are not registered in MIMEMapping.
If the request has no extension, Magnolia assumes it is
Matching requests to content types
You can restrict responses to match content types with the
To force content type matching, add the
validateContentType property in
server/filters/contentType and set the value to
validateContentType property is set to
true, Magnolia will respond with response code 400 if the requested extension does not match the content type. This property essentially disables all unknown extensions.