Make WordPress Core

Opened 5 months ago

Last modified 3 months 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 (4)

#1 @jrf
5 months ago

  • Focuses accessibility php-compatibility removed

#2 @jrf
5 months ago

  • Component changed from Security to Rewrite Rules

#3 @deepakvijayan
5 months 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

#4 @QROkes
3 months ago

I can confirm this issue!

Also, it only happens when the SSL Cert (HTTPS) is set before running the initial WP installation (install.php). If the SSL Cert is set on an existing site (after install.php), this issue is not present.

Note: See TracTickets for help on using tickets.