[wp-trac] [WordPress Trac] #60330: redirect that working incorrectly!
WordPress Trac
noreply at wordpress.org
Tue Jan 23 19:57:30 UTC 2024
#60330: redirect that working incorrectly!
----------------------------------------------+----------------------------
Reporter: markuscode | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Security | Version:
Severity: normal | Keywords:
Focuses: accessibility, php-compatibility |
----------------------------------------------+----------------------------
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
<?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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60330>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list