Trailing slash added to directories
All shared web hosting servers automatically add a trailing slash to requests for directories. For example:
https://example.com/directoryredirects tohttps://example.com/directory/https://example.com/2024/05/30/your-new-postredirects tohttps://example.com/2024/05/30/your-new-post/
This behavior (DirectorySlash On) cannot be modified on shared hosting. If you need to change it, you would need a cloud vps.
Why this behavior exists
Section titled “Why this behavior exists”There are security and usability reasons for this on LiteSpeed/Apache:
- Ensures the user requests the canonical URL of the resource
- Allows
mod_autoindexto function correctly with proper relative paths DirectoryIndexis only evaluated for directories requested with a trailing slash- Relative URL references inside HTML pages resolve correctly