A custom WordPress module takes certain int
variable directly from the PHP_URL_PATH
roughly like this:
private function myIdVariable() {
$myid = 0;
// Support both URL formats: /path/123 and /path/?myid=123
$lastpartofurl = (int) basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$myid = (int) isset($_GET['myid']) ? $_GET['myid'] : $lastpartofurl;
return $myid;
}
Here, the /path/
is the SEO optimized path for the post/article where this module is used, and there's no articles in /path/subpath
.
Before the WordPress 5.5 update this worked, but now /path/123
gets automatically redirected to /path/
. It should result as the same page as /path/?myid=123
for prettier URLs giving better SEO.
Results from the Monkeyman Rewrite Analyzer shows this matches (.?.+?)?(:/([0-9]+))?/?$
.
As this code supports two URL formats, there's a workaround by adding a RedirectMatch
, e.g.
RedirectMatch ^/path/([0-9]+)$ "/?myid=$1"
However, for a real fix I would like to know:
- What might have added this redirection in WordPress 5.5?
- Is it configurable?
- Is this change in the URL behaviour intended in WordPress 5.5, or should I report a bug?