Clear Trailing Slash

Overview

The ClearLastSlash rule in Forge Server's forgerc configuration removes a trailing slash from URLs when enabled. This rule can be applied globally to all URLs or nested within a Location block for more granular control.

Usage

The ClearLastSlash rule accepts a boolean value:

  • true – Enables the removal of the trailing slash.
  • false – Disables the removal of the trailing slash (default behavior if not specified).

Global Configuration

Applying ClearLastSlash globally ensures that all URLs processed by the server automatically remove a trailing slash if present.

Example

ClearLastSlash true

Location /sdk
  Rewrite /sdk/index.html

Location /guides/deployment-options
  Rewrite /guides/deployment-options/index.html

In this example:

ClearLastSlash true ensures that all URLs have their trailing slash removed before further processing.

The Rewrite directives inside Location blocks remain unaffected by this rule.

Considerations

  • Ensure that enabling ClearLastSlash does not conflict with expected routing behavior in your application.
  • URLs without a trailing slash remain unchanged.

Join the Discussion

Have questions about this topic or want to share your experience? Join our community discussion!

Visit Forum Discussion