pdoTools icon indicating copy to clipboard operation
pdoTools copied to clipboard

Incorrect next/prev canonical URLs

Open sdrenth opened this issue 4 years ago • 1 comments

With link_tag_scheme set to abs and a website which has a base_url set to /en-en/ the generated prev/next canonical URLs are incorrect, having a duplicate /en-en/.

Example output:

<link rel="canonical" href="https://www.domain.tld/en-en/en-en/products"/>
<link rel="next" href="https://www.domain.comtld/en-en/en-en/products?page=2"/>

This is due to the getBaseUrl function in pdoPage class.

$host = '';
switch ($this->pdoTools->config['scheme']) {
    case 'full':
        $host = $this->modx->getOption('site_url');
        break;
    case 'abs':
    case 'absolute':
        $host = $this->modx->getOption('base_url');
        break;
    case 'https':
    case 'http':
        $host = $this->pdoTools->config['scheme'] . '://' . $this->modx->getOption('http_host') .
            $this->modx->getOption('base_url');
        break;
}
$url = $host . $q_val;

I think this should be altered to?

case 'abs':
case 'absolute':
    $host = '';
    break;

sdrenth avatar Dec 03 '21 13:12 sdrenth

Fixed in MODX 3.

sergant210 avatar Aug 01 '22 17:08 sergant210