Add trailing slash /

Created on 17 January 2018, over 7 years ago
Updated 6 August 2024, 8 months ago

We are having an issue where we can't create links relative to current page because there are no trailing slashes at the end of URL.

For example:

If you have domain.com/fruits/apple
and in that page you want to create a link to TIPS by adding a href="TIPS" or href="./TIPS", you can't.

Because you will end up at
domain.com/fruits/TIPS
instead of the intended path
domain.com/fruits/apple/tips

Which would only work properly if the current page URL was:
domain.com/fruits/apple/
and not domain.com/fruits/apple

In this case, we are working with taxonomy term pages, but the same applies to any Drupal page.

Can we make the redirect module support trailing slashes? I can see that the Global Redirect had support for this.

Or is this something that can / should be set in htaccess?

Any help is greatly appreciated.

πŸ› Bug report
Status

Postponed: needs info

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tepelena

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡ΊπŸ‡ΈUnited States brad.bulger

    To #9, these aren't Drupal relative paths, they are HTML relative links. The href value does not start at the root of the site, it's relative to the current URL.

    It is not a question of preference. /base and /base/ have different semantics. In many cases, the difference is unimportant. But it is important when there are relative URLs.

    • child relative to /base/ is /base/child.
      on https://my.site/base/ <a href="child">child</a> links to https://my.site/base/child
    • child relative to /base is (perhaps surprisingly) /child.
      on https://my.site/base <a href="child">child</a> links to https://my.site/child

    - When should I use a trailing slash in my URL? (Examples added)

    For SEO, as far as I can tell, the important thing is to be able to have a single canonical version that you use throughout the site. Maybe any kind of global setting is in conflict with that. I don't think you can define aliases that end with a slash, so I don't know how you would be able to define one item as ending with a slash and another item not.

Production build 0.71.5 2024