Skip to:

Opened 7 years ago

Last modified 6 years ago

#7555 new defect (bug)

BuddyPress Canonical Redirects and Trailing Slashes

Reported by: megaz's profile MegaZ Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 1.5
Component: Core Keywords: needs-patch



By default, BuddyPress adds a trailing slash to all slug pages, no matter what Permalink structure is set in WordPress. While this works well for a typical WordPress permalink structure like "/%postname%/" if I change my permalink structure to get rid of the trailing slash like "/%postname%" then BuddyPress does not take this into account and still continues to keep all the content with a trailing slash at the end. As a result, URLs such as the members page that are not supposed to have trailing slashes will still contain them, such as "/members/", whereas it is supposed to be just "/members".

The issue lies in the bp_get_canonical_url function within the bp-core-catchuri.php file, where one single line always forces trailing slashes on all URLs:

url_stack[0] = trailingslashit( $url_stack[0] );

Instead of doing this, why not change the function to "user_trailingslashit", so that the slash is removed or added based on the permalink structure? Once done, the code properly redirects the user to the right URL and does not generate the unnecessary trailing slash.

It seems like BuddyPress employs such techniques in a number of areas where the function utilizes link generation. I wonder why the development team went this route, instead of staying consistent with the WordPress permalink structure.

Change History (4)

#1 @johnjamesjacoby
7 years ago

  • Milestone changed from Awaiting Review to 2.9

I tend to agree.

Related #7448, cc @r-a-y.

#2 @r-a-y
7 years ago

  • Priority changed from high to normal
  • Version changed from 2.8.2 to 1.5

We've been using trailingslashit() for years and this is the first time that this has been reported.

So I think 3.0 might be a better milestone for this as this will require touching all our template and redirect URLs. What @MegaZ notes about changing bp_get_canonical_url() is just one part of the equation.

@jjj - If you feel this is important to fix for 2.9, then feel free to address this.

#3 @hnla
7 years ago

  • Milestone changed from 2.9 to 3.0

Will have to be dealt with in 3.0 now.

#4 @DJPaul
6 years ago

  • Milestone changed from 3.0 to Awaiting Contributions
Note: See TracTickets for help on using tickets.