The voice of The Apache Software Foundation

Serving Clean URLs via Custom Internet Media Types on Tomcat Garret Wilson

September 12, 2019

Increasingly static site generators are being used to create a presence on the web, both for the speed and simplicity of the resulting static pages. A related trend is the use of ‘clean’ URLs with no resource name extensions, such as `/products/mousetrap` instead of `/products/mousetrap.html`. Clean URLs are more memorable, less fragile, do not leak implementation information, and are more search engine friendly. Because the default Tomcat implementation determines MIME type by filename extension, ‘clean’ filenames are traditionally produced by servlet mapping or URL rewriting, perhaps coupled with Apache HTTP Server in front of Tomcat using `mod_rewrite`. This presentation shows how Tomcat has been extended to dynamically determine MIME type at runtime based on metadata stored in a parallel file tree or as sidecar files, and to serve the pages with clean resource names directly from Tomcat with no need for URL rewriting. A tutorial on the static site generator Guise Mummy is also included, illustrating how to generate a static site with clean resource names, host the site immediately using embedded Tomcat, and/or deploy the site to AWS S3 using bucket object metadata with a single command.

Leave a Reply

Powered by WordPress.com.
%d bloggers like this: