Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 13 years ago

#2681 closed defect (bug) (fixed)

Canonicalization of Buddypress URLs

Reported by: lucianop's profile lucianop Owned by: boonebgorges's profile boonebgorges
Milestone: 1.6 Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch
Cc:

Description

When I visit a BuddyPress-generated URL (such as http://example.com/activity), I am not redirected to a properly canonicalized url.

For example, I can go to:

http://example.com/activity
http://example.com/activity/

In Wordpress, the default behavior is whether I type the url without trailing slash, I get redirected to the canonicalized version (with trailing slash).

Attachments (2)

2681.001.patch (707 bytes) - added by r-a-y 14 years ago.
2681.002.patch (2.0 KB) - added by boonebgorges 13 years ago.

Download all attachments as: .zip

Change History (9)

#1 @boonebgorges
14 years ago

  • Milestone changed from 1.3 to 1.4

This would be worth doing but it probably won't happen for 1.3 unless someone provides a patch.

#2 @r-a-y
14 years ago

Interestingly, changing Wordpress' canonical action hook from "template_redirect" to "get_header" fixes this for BuddyPress.

No time for a patch, but try changing this line in /wp-includes/canonical.php:

add_action('template_redirect', 'redirect_canonical');

to:

add_action( 'get_header', 'redirect_canonical', 0 );

Not sure if there are any side-effects with doing this.

@r-a-y
14 years ago

#3 @r-a-y
14 years ago

  • Keywords has-patch added; url canonicalization removed

The patch checks if the current page is a blog page ( WP page, post, archive, etc. ) with bp_is_blog_page(), then adds a hook to "get_header" with a priority of zero, so it runs first, directly after "template_redirect"; "get_header" is the action following "template_redirect".

---

Tested lightly; it redirects BP pages to their trailingslashit equivalent.

Anchors in URLs are preserved; haven't checked queries, but should work as well.

Version 3, edited 14 years ago by r-a-y (previous) (next) (diff)

#4 @DJPaul
13 years ago

  • Owner set to boonebgorges
  • Severity set to normal
  • Status changed from new to assigned

Related to #1741

#5 @boonebgorges
13 years ago

2681.002.patch is the function that I've come up with to handle this. I've hooked it to a new do_action() in bp_core_load_template(), so that the redirect only takes place for pages that are viewable in a browser (mimicking the fact that WP does the redirect at template_redirect).

This patch will have to be accompanied by a gigantic audit of our own redirect and URL-building functions. We want to avoid redirects where possible, so we should be building our URLs appropriately - with the trailing slash. I'll work on it. In the meantime, feedback welcome on 2681.002.

#6 @boonebgorges
13 years ago

(r-a-y, I couldn't get your patch to work right. WP's redirect_canonical didn't seem to do anything for me.)

#7 @boonebgorges
13 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Whoops, this was fixed in r5412.

Note: See TracTickets for help on using tickets.