News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Canonical URL Issue

Started by MobileCS, November 14, 2023, 11:37:28 AM

Previous topic - Next topic

MobileCS

I just noticed in Google search console that I have 2,500 (and climbing) URL's with "Alternate page with proper canonical tag" issues.

I'm seeing a weird issue concerning that. I have search engine friendly URL's turned on (it's been on for 15+ years, so I can't turn it off for SEO sake).

My URL is :
https://www.example.com/forum/index.php/topic,61952.0.html

If I am logged in, the canonical tag shows the same as above.

If I'm not logged in, the canonical tag shows as :
https://www.example.com/forum/index.php?topic=61952.0

Any idea why this is - and how I can fix it?

MobileCS

I'm not sure if it's the right way to fix it, but to stop the bleeding this seems to be working :

In Sources/Display.php :

Find:
$context['canonical_url'] = $scripturl . '?topic=' . $topic . '.' . ($can_show_all ? '0;all' : $context['start']);

Replace:
$context['canonical_url'] = $scripturl . '/topic,' . $topic . '.' . ($can_show_all ? '0/all.html' : $context['start'] . '.html');

Advertisement: