Make WordPress Core

Opened 8 years ago

Last modified 3 years ago

#15950 new enhancement

Tweak canonical redirect name requests

Reported by: johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Canonical Keywords: dev-feedback needs-patch
Focuses: Cc:


Scenario: A website has the following two pages:

  • example.com/foo/amazing-thing/
  • example.com/amazing/

Upon requesting example.com/amazin the canonical redirect should favour the top-most level page. This doesn't happen as the relevant SQL query doesn't have an ORDER BY clause, making the behaviour unpredictable.

Attachments (1)

15950.patch (633 bytes) - added by johnbillion 8 years ago.

Download all attachments as: .zip

Change History (9)

8 years ago

#1 @johnbillion
8 years ago

  • Keywords has-patch added
  • Version set to 3.1


#2 @nacin
8 years ago

  • Milestone changed from Awaiting Review to Future Release

That would then cause example.com/foo/amazin to be redirected to example.com/amazing/ rather than example.com/foo/amazing/.

#3 @johnbillion
8 years ago

  • Keywords has-patch removed
  • Type changed from enhancement to defect (bug)

This is actually a bug then. Only the last part of the URL (ie. the 'name' query var) is used to guess the correct page.

The resulting SQL when requesting either example.com/foo/amazin or example.com/amazin both look like this:

SELECT ID FROM wp_posts WHERE post_name LIKE 'amazin%' AND post_status = 'publish'.

Not sure how to address this. Not sure if the return on investment in time fixing it is actually worth it.

#4 @nacin
8 years ago

  • Keywords has-patch added
  • Type changed from defect (bug) to enhancement

Never mind then. I just postulated, but forgot about how the query worked.

#5 @dd32
8 years ago

This has bugged me before..

Ideally, My solution would be:

Take the requested uri, strip the homeurl off it. If it looks like a page, AND there is a / in the url, lookup that page, search for children of this page which matches the final component of the uri. If no match, revert to searching all pages.

#6 @chriscct7
4 years ago

@dd32 did you want to revisit this?

#7 @chriscct7
3 years ago

  • Keywords dev-feedback added

#8 @johnbillion
3 years ago

  • Keywords needs-patch added; has-patch removed
Note: See TracTickets for help on using tickets.