Ticket #12456 (accepted enhancement)
Canonical URL redirect issue with post_id/postname permalink structure
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Canonical | Version: | 2.9.2 |
| Severity: | normal | Keywords: | has-patch tested 3.3-early |
| Cc: | hlanggo |
Description
The issue:
Using /%post_id%/%postname%/ as permalink structure, Most canonical redirects work fine, except:
domain.com/post_id/ brings you to the post but does not redirect to the canonical domain.com/post_id/postname/
Additional info:
The above permalink structure conforms to best practice as described in the codex: http://codex.wordpress.org/Using_Permalinks#Structure_Tags
Therefore I figured this was a bug, given the attention given to redirecting to the canonical url "So to avoid confusing search engines and to consolidate your rankings for your content, there should only be one URL for a resource." http://markjaquith.wordpress.com/2007/09/25/wordpress-23-canonical-urls/
Attachments
Change History
- Owner changed from ryan to markjaquith
- Component changed from Permalinks to Canonical
- Milestone changed from Unassigned to 3.0
- Keywords has-patch needs-testing added; permalinks canonical redirect removed
- Type changed from defect (bug) to enhancement
- Milestone changed from 3.0 to 3.1
It doesnt appear that Redirecting Rewritten URL's has ever been handled by the Canonical system for WordPress. Most of the code is for redirecting ?query=var to /query/something/var/.
I'm going to attach a little-tested patch, please test it out, and try to break it if possible :)
IMO, This may be fitting in as an enhancement since its not currently a handled case and is not a regression, which would mean relegating it to 3.1 as we're in 3.0 feature freeze.
comment:3
in reply to:
↑ 2
;
follow-up:
↓ 4
Frank.Prendergast — 2 years ago
Thank you so much for coming back to me on this. I've implemented the patch on a test site using the nightly build and so far so good.
I wasn't able to try it on my main site because I wouldn't know how to implement the patch as the canonical.php is different, so proper & full tire kicking might need to wait until 3.0 is ready for implementing on my main site.
Many thanks again. This could provide people with a nice little url shortening tool without risking losing any "Google juice" if people link to the propogated shorter url.
comment:4
in reply to:
↑ 3
Frank.Prendergast — 2 years ago
(My main site being WP 2.9.2)
comment:5
in reply to:
↑ 2
Frank.Prendergast — 23 months ago
Just to check back and say that I've had this patch on a test install I use for development and haven't run into any issues with it.
Thank you again, and let me know if I should do anything else (first time submitting anything to trac).
- Keywords tested early added; needs-testing removed
- Owner changed from markjaquith to dd32
- Status changed from new to accepted
Thanks for getting back to me that it works as expected.
I'm not going to add this to 3.0 due to how close we are to release, so it'll be in 3.1
Noticed this one yesterday. This is definitely a problem that needs to be resolved. Recommend pushing it into the next release.
- Cc hlanggo added
/postname/post_id also has the same problem. /postname shows the correct page but doesn't redirect to the canonical /postname/post_id
With /postname/post_id (no ending slash) permalink structure:
Canonical: http://metroparkhotelcebu.com/mph/138 (/postname/post_id) Redirect OK: http://metroparkhotelcebu.com/138/mph (/post_id/postname) No redirect: http://metroparkhotelcebu.com/mph (/postname) 404: http://metroparkhotelcebu.com/138 (/post_id)
Yes, I am aware that using postname first causes performance issues but back when I decided on it, http://codex.wordpress.org/Using_Permalinks said it was okay to start with postname. Thankfully, my sites are small so the performance problems aren't debilitating.
comment:10
dd32 — 17 months ago
hlanggo: Did you try the attached patch at all?
comment:11
hlanggo — 16 months ago
No, I did not try the patch. Just wanted to report that /postname/post_id has the same redirect issue as post_id/postname
It's the "starting with postname" performance issue which concerns me the most. I just came across your ticket while searching about it.
comment:12
jane — 15 months ago
- Milestone changed from 3.1 to Future Release
Punting this enhancement ticket b/c we are going into beta. Can reconsider for 3.2 when there is a well-tested patch.
comment:13
dd32 — 14 months ago
- Keywords 3.2-early added; early removed
planning on covering this, and a few other cases such as #14773 in 3.2
comment:14
dd32 — 8 months ago
- Keywords 3.3-early added; 3.2-early removed
Missed the boat for 3.2 again.
This covers #17653 as well.
comment:15
dd32 — 8 months ago
Patch doesnt cover /page/xx/ redirections and a few others probably.

