Skip to content

Clean URLs & Default Indexing

Darshan edited this page Oct 27, 2024 · 1 revision

With Clean URLs, you can remove file extensions from the URL path, making the URLs shorter and more user-friendly.

Example: Access functions.app/contact instead of functions.app/contact.html.

Enabling Clean URLs

To enable Clean URLs for specific file extensions, use:

appExpress.cleanUrls(['html', 'txt']);

The cleanUrls function accepts an array of file extensions to exclude from URLs, ensuring that paths are simplified without changing file structure.


Using Default Index Files

You can also enable default indexing to serve index.html automatically for directories:

appExpress.serveIndex(true);

With this enabled:

  • Navigating to / will serve index.html.
  • Navigating to /contact will serve contact/index.html.

This feature allows users to access directory-based content seamlessly, further improving URL readability and usability.

Clone this wiki locally