Configuring Apache for MetacatUI

There are two Apache configurations needed for MetacatUI to work properly.

  1. Configure Apache to serve index.html instead of a 404 for the MetacatUI directory
  2. Allow encoded slashes in MetacatUI paths

Configure Apache to serve index.html instead of a 404 for the MetacatUI directory

Why do I need this?

MetacatUI is a single-page Javascript application which uses a single index.html file to initialize the MetacatUI app. The app checks the path that the user has navigated to (e.g. /data/page/2), and renders the corresponding view. Then MetacatUI listens to each link click in the app and renders the next view for that link.

This means there is no server-side application or files that are serving up HTML responses for each MetacatUI path.

For this all to work, you need to tell your web server to serve the index.html MetacatUI page for every MetacatUI path. Otherwise, your server will return a 404 error.

Apache v2.2.16 and later

Add the FallbackResource Apache directive:

  ...
  # Serve index.html instead of a 404 error in the MetacatUI directory
  <Directory "/var/www/metacatui">
    FallbackResource /metacatui/index.html
  </Directory>
  ...

Apache v2.2.15 and earlier

Add a mod_rewrite Apache directive for the MetacatUI index.html file:

  <Directory "/var/www/metacatui">
  ...
  ...

  <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]
  </IfModule>
  </Directory>

Allow encoded slashes in MetacatUI paths

Add the following to your Apache configuration file:

...
# Allow encoded slashes in URLs so encoded identifiers can be sent in MetacatUI URLs
AllowEncodedSlashes On
...

Why do I need this? / characters are commonly used in identifiers for data and metadata objects in Metacat repositories. These identifiers are used in MetacatUI paths and are usually URL-encoded.

Configuring Apache locally on Mac OS X, for MetacatUI development

Note: The following instructions are general guidelines on how to set up a local Apache server so you can develop MetacatUI features/bugs on your local machine. These instructions are not updated regularly, since we recommend you use the NodeJS Express server instead.

Step 1. Create a directory for your MetacatUI

Step 2. Tell Apache to use the directory from Step 1

Step 3. Configure a VirtualHost in Apache for MetacatUI

Step 4. Move MetacatUI files to Apache

Step 5. Start Apache