Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#60330 new defect (bug)

redirect that working incorrectly!

Reported by: markuscode's profile markuscode Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Rewrite Rules Keywords:
Focuses: Cc:

Description

Issues that once you going to for example https://example.com/example-page-slug/1000/ will redirect you to https://example.com/example-page-slug/ . But it's supposed to display 404 page. Is bad for SEO because that redirect using 301.

<?php

class RedirectFixer {
        function __construct(){
                add_filter('request', array($this, 'request'),10,1);
        }

        function request($query) {
                if(isset($query['page']) && (int)$query['page'] > 0) {
                        $query = array(
                                'pagename' => '404'
                        );
                }
                return $query;
        }
}
new RedirectFixer();

This is how to fix it.

Change History (3)

#1 @jrf
5 weeks ago

  • Focuses accessibility php-compatibility removed

#2 @jrf
5 weeks ago

  • Component changed from Security to Rewrite Rules

#3 @deepakvijayan
4 weeks ago

I gave it a go myself, and I'm seeing the same behaviour as you reported. URLs like https://example.com/example-page-slug/1000/ are redirecting to https://example.com/example-page-slug/ instead of showing a 404 page. That 301 redirects isn't doing our SEO any favours.

Environment

  • WordPress: 6.4.3
  • PHP: 7.4.33
  • Server: Apache/2.4.54 (Unix) OpenSSL/1.0.2u PHP/7.4.33 mod_wsgi/3.5 Python/2.7.18 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.11 Perl/v5.30.1
  • Database: mysqli (Server: 5.7.39 / Client: mysqlnd 7.4.33)
  • Browser: Chrome 121.0.0.0 (macOS)
  • Theme: Twenty Twenty-Four 1.0
  • MU-Plugins: None activated
  • Plugins:
    • WordPress Beta Tester 3.5.5
Note: See TracTickets for help on using tickets.