[wp-trac] [WordPress Trac] #20902: redirect_canonical() on using permalink: Not all $_GET being redirected

WordPress Trac noreply at wordpress.org
Thu Aug 28 10:31:45 UTC 2025


#20902: redirect_canonical() on using permalink: Not all $_GET being redirected
-------------------------------------------------+-------------------------
 Reporter:  arieputranto                         |       Owner:  chriscct7
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:
Component:  Canonical                            |     Version:  3.4
 Severity:  normal                               |  Resolution:
 Keywords:  good-first-bug has-patch has-unit-   |     Focuses:
  tests changes-requested                        |
-------------------------------------------------+-------------------------

Comment (by kalpeshh):

 == Bug Report

 === Description
 Canonical redirects from query vars (`post_format`, `pagename`,
 `author_name`, `category_name`) to pretty permalinks are inconsistent.
 `Pagination requests` with `paged=1` on `post_format` and `category_name`
 remain on the query-string form instead of redirecting to the canonical
 pretty URL.

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.27.5
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - Browser: Chrome 138.0.0.0
 - OS: Linux
 - Theme: Twenty Twenty-Five 1.2
 - MU Plugins: None activated
 - Plugins:
   * Test Reports 1.2.0

 === Steps to Reproduce

 Enable pretty permalinks (`/%postname%/`).

 Visit the URLs listed below in a browser or with curl -I.

 === Expected Results

 ✅ /?pagename=blog → /blog/

 ✅ /?author_name=admin → /author/admin/

 ✅ /?category_name=cat → /category/cat/

 ✅ /?post_format=image → /type/image/

 ✅ Pagination should canonicalize:

 &paged=1 should either redirect to the base archive or /page/1/
 consistently.

 &paged>1 should redirect to /.../page/{n}/.

 ✅ Extra query args should be preserved in redirect.

 ✅ Invalid values (nopage, unknown author, random post_format, nocat)
 should not redirect and return 404.

 === Actual Results

 ✅ http://localhost:8889/type/image/ → redirects correctly

 ❌ http://localhost:8889/?post_format=image&paged=1 → stays on query form
 (no redirect)

 ✅ http://localhost:8889/?post_format=random → 404 as expected

 ✅ http://localhost:8889/?pagename=blog → redirects correctly

 ✅ http://localhost:8889/?pagename=blog&utm_source=test&foo=bar →
 redirects correctly preserving parameters

 ✅ http://localhost:8889/?pagename=nopage → 404 as expected

 ✅ http://localhost:8889/?author_name=admin → redirects correctly

 ✅ http://localhost:8889/?author_name=admin&paged=1 → redirects correctly
 with pagination

 ✅ http://localhost:8889/?author_name=unknown → 404 as expected

 ✅ http://localhost:8889/?category_name=cat → redirects correctly

 ❌ http://localhost:8889/?category_name=cat&paged=1 → stays on query form
 (no redirect)

 ✅ http://localhost:8889/?category_name=nocat → 404 as expected

 === Additional Notes

 The issue is happening with **paged=1** requests for **post_format** and
 **category_name**.

 Either it should redirect with paged=1 query parameter or normalize it to
 /page/1/.


 === Supplemental Artifacts
 Screenshots for failing requests.
 [[Image(pagination-issue.png)]]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/20902#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list