Make WordPress Core

Opened 16 years ago

Closed 14 years ago

#6516 closed enhancement (fixed)

canonical redirect doesn't redirect ?name=slug

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by: markjaquith's profile markjaquith
Milestone: 2.9 Priority: normal
Severity: major Version: 2.5
Component: Canonical Keywords: needs-patch
Focuses: Cc:

Description

domain.com?name=test doesn't seem to be redirecting to domain.com/2008/03/31/test/

Attachments (1)

6516.diff (2.9 KB) - added by DD32 15 years ago.

Download all attachments as: .zip

Change History (17)

#1 @Denis-de-Bernardy
16 years ago

same goes for pagename, and presumable others

#2 @DD32
16 years ago

I believe that'd be the expected result, at least with the 2.5 branch.

If you were to try domain.com/test it would indeed redirect as expected.

AFAIK, It ignores query vars which it doesnt know about. If you were to access domain.com?p=<post id> then it'd also redirect.

#3 @Denis-de-Bernardy
16 years ago

mm, aren't name and pagename (and several others) built-in query vars for WP? If WP cannot reliably redirect things other than ?p=ID, it's really not worth calling this a canonical permalink feature (or whatever it's called). I'd hate to have to reinstall permalink redirect... :-|

#4 @lloydbudd
16 years ago

  • Milestone changed from 2.5.1 to 2.7
  • Summary changed from canonical redirect broken to canonical redirect doesn't redirect ?name=slug
  • Type changed from defect to enhancement

#5 @lloydbudd
16 years ago

  • Milestone changed from 2.7 to 2.6

@DD32
15 years ago

#6 @DD32
15 years ago

  • Component changed from Optimization to Canonical
  • Keywords has-patch needs-testing added
  • Milestone changed from 2.9 to 2.8
  • Owner changed from anonymous to markjaquith

attachment 6516.diff added.

  • Redirects ?name and ?pagename to their permalinks
  • WP_Query changes:
    • supports querying based on 'pagename' for pages which are not a static front page
    • if ( !empty($reqpage) ) was added to prevent querying for page_id == 0, which happens when pagename is a slug & a the page is a subpage (in that case, get_page_by_path() will fail)
    • if ('' != $q['name']) block was moved after page/attachment code to reduce duplicate code

#7 @DD32
15 years ago

Hmm.. Those changes to WP_Query may've been in the wrong thinking, Page slugs are not unique (as is with attachments/posts)

#8 @Denis-de-Bernardy
15 years ago

true, but isn't redirecting to something plausible better than outputting a 404?

#9 @ryan
14 years ago

is_single() and is_page() mean we requested a single object. Can we not use get_queried_object_id() and pass that to get_permalink()?

#10 @Denis-de-Bernardy
14 years ago

Imo, we should close this one, and open a grand ticket: Enforce permalink history across the board.

#11 follow-up: @DD32
14 years ago

Can we not use get_queried_object_id() and pass that to get_permalink()?

Yes, Yes we can. (Except that i'm not aware of the usage of function such as those :))

#12 in reply to: ↑ 11 @Denis-de-Bernardy
14 years ago

Replying to DD32:

Can we not use get_queried_object_id() and pass that to get_permalink()?

Yes, Yes we can. (Except that i'm not aware of the usage of function such as those :))

Like this:

get_permalink($wp_query->get_queried_object_id());

#13 @Denis-de-Bernardy
14 years ago

  • Keywords needs-patch added; has-patch needs-testing removed
  • Milestone changed from 2.8 to Future Release

Bumping to Future

#14 @Denis-de-Bernardy
14 years ago

  • Milestone changed from Future Release to 2.9

#15 @ryan
14 years ago

(In [11745]) Canonical redirects for post name queries. Props DD32. see #6516

#16 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.