Repository navigation
Redirect paginated homepage requests to the homepage - #3694
Open
muneeb-ashraf wants to merge 1 commit into
Open
muneeb-ashraf wants to merge 1 commit into
muneeb-ashraf wants to merge 1 commit into
Conversation
Requests such as /page/4/ returned a 200 with the homepage content. Send them to the homepage with a 301 instead. Fixes WordPress#2480. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W6LxjEQnP4PPgXXvAM3M2F
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2480.
What
Paginated views of the homepage, such as https://learn.wordpress.org/page/4/, currently return a
200with the homepage content. This adds atemplate_redirecthandler ininc/redirects.phpthat sends them to the homepage with a301, next to the existing redirects.The check covers both ways WordPress can represent
/page/N/on the front page:is_paged()when the front page shows the latest posts.get_query_var( 'page' ) > 1when a static page is the front page, since WordPress movespagedtopagein that case.Paginated archives, search results and the first page of the homepage are not affected.
Testing
I ran these cases against WordPress trunk with a throwaway PHPUnit test that loads
inc/redirects.phpand firestemplate_redirect:/page/2///page/2////category/news/page/2//page/2/?s=postWithout the change, the two
/page/2/cases don't redirect (core'sredirect_canonical()leaves them alone).composer run lintrules pass on the changed file.To check manually after deploy:
curl -sI https://learn.wordpress.org/page/4/should return301withLocation: https://learn.wordpress.org/.AI assistance
🤖 Generated with Claude Code
https://claude.ai/code/session_01W6LxjEQnP4PPgXXvAM3M2F