Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect next/prev canonical URLs #318

Open
sdrenth opened this issue Dec 3, 2021 · 1 comment
Open

Incorrect next/prev canonical URLs #318

sdrenth opened this issue Dec 3, 2021 · 1 comment
Labels

Comments

@sdrenth
Copy link

sdrenth commented Dec 3, 2021

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 sdrenth added the bug label Dec 3, 2021
@sergant210
Copy link
Member

Fixed in MODX 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants