Canonical links having "&" in URL

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
ShadeUT99
Registered User
Posts: 10
Joined: Sun Sep 08, 2019 10:28 am

Canonical links having "&" in URL

Post by ShadeUT99 »

Hello :)

I just noticed that canonical links have "&" instead of "&" in their title when there is a start parameter.
Example:

Code: Select all

https://www.example.com/viewtopic.php?t=2508&start=15
Is there a way to correct this by myself or is a bug actively being worked on? Or is it working as intended?

Regards
Shade
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6673
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Canonical links having "&" in URL

Post by HiFiKabin »

If you are referring to the board in your profile, it looks correct here

https://ut99.org/viewtopic.php?t=15400&start=15


&.png
&.png (4.61 KiB) Viewed 656 times
User avatar
janus_zonstraal
Registered User
Posts: 6418
Joined: Sat Aug 30, 2014 1:30 pm

Re: Canonical links having "&" in URL

Post by janus_zonstraal »

Are there Canonical links in a standard phpbb installation?
Sorry! My English is bat ;) !!!
User avatar
ShadeUT99
Registered User
Posts: 10
Joined: Sun Sep 08, 2019 10:28 am

Re: Canonical links having "&" in URL

Post by ShadeUT99 »

HiFiKabin wrote: Wed Jan 25, 2023 9:20 am If you are referring to the board in your profile, it looks correct here

https://ut99.org/viewtopic.php?t=15400&start=15



&.png
Maybe I should have specified. I am talking about the canonical link in the source code:

Code: Select all

<link rel="canonical" href="https://www.example.com/viewtopic.php?t=14061&amp;start=15">
janus_zonstraal wrote: Wed Jan 25, 2023 9:21 am Are there Canonical links in a standard phpbb installation?
Yes. For example, a topic can be accessed via /viewtopic.php?f=5&t=14061 and /viewtopic.php&t=14061 (without forum parameter). The second one is the canonical URL.
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6673
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Canonical links having "&amp;" in URL

Post by HiFiKabin »

because & is HTML for "Start of a character reference" eg

Code: Select all

&amp; 		&
&lt; 		<
&gt; 		>
&quot; 		"
and so on
User avatar
ShadeUT99
Registered User
Posts: 10
Joined: Sun Sep 08, 2019 10:28 am

Re: Canonical links having "&amp;" in URL

Post by ShadeUT99 »

HiFiKabin wrote: Wed Jan 25, 2023 11:33 am because & is HTML for "Start of a character reference" eg

Code: Select all

&amp; 		&
&lt; 		<
&gt; 		>
&quot; 		"
and so on
In a URI a "&" states the beginning of a a new parameter while "&amp;" means literally "just a &, no new parameter".
So if a URI in a link in the source code has "&amp;" in it, the parameter after that is ignored.

You can test it yourself:
/viewtopic.php?t=15400&start=15 -> This jumps to the 15th post
/viewtopic.php?t=15400&amp;start=15 -> This does not jump to the 15th post.

Having a canonical link like <link rel="canonical" href="https://example.com/viewtopic.php?t=15400&amp;start=15"> is therefore not correct and I fear it interferes with earch engine crawlers trying to correctly index the forum.

But maybe I am missing something?
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6673
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Canonical links having "&amp;" in URL

Post by HiFiKabin »

Firstly never underestimate the cleverness of search engines. They can index any vanilla phpBB board without any problems.

Secondly I think you are confusing what you write in the search box and what is entered from a HTML page.

If you want & to appear in the search bar, then you put the HTML &amp; in the HTML code

More Reading which might help make things clearer.
User avatar
ShadeUT99
Registered User
Posts: 10
Joined: Sun Sep 08, 2019 10:28 am

Re: Canonical links having "&amp;" in URL

Post by ShadeUT99 »

Thank you for the detailed answer. Unfortunately I still dont understand why there is an &amp; and not an & in the href-value (/viewtopic.php?t=14061&amp;start=15). Because technically that way the next parameter in the URI is not called "start" but "amp;start", as the whole URI is in quotation marks and a "&amp;" will be just read as such and not translated to &. Even if you copy the href-value and put it into the browser address bar yourself, you will see that the browser will not translate "&amp;" to "&" and will therefore not read the "start"-parameter correctly and points to the beginning to a thread.

But you said I should not underestimate the cleverness of search engines and that they can index any vanilla phpBB board without any problems.
So this gives me peace that search engines are accommodating in this case. :)

(Still I dont know what speaks agains just putting a "&" instead of "&amp;" in the href-value. But the devs might have a reason for that I am not aware of.)

Thanks again!
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53400
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Canonical links having "&amp;" in URL

Post by Brf »

I think you are worrying over a non-existent problem. As you can see here, your browser interprets the link (with &amp) just fine. Clicking through brings up the proper page.
Attachments
canonical.png
User avatar
ShadeUT99
Registered User
Posts: 10
Joined: Sun Sep 08, 2019 10:28 am

Re: Canonical links having "&amp;" in URL

Post by ShadeUT99 »

Brf wrote: Fri Jan 27, 2023 5:01 pm I think you are worrying over a non-existent problem. As you can see here, your browser interprets the link (with &amp) just fine. Clicking through brings up the proper page.
A search engine crawler does not "click" on a link in a code. It parses the URL and tries to access it. That it works for the search engine crawlers just maybe means that they are clever and accommodating and can correct URLs.

Its like if you would copy the url and paste it in the browser address bar to try to open it. Try it out and see what happens. You have to spot the error and manually correct the URL to make it work correctly (just like a crawler most likely does it).

But maybe.... I am still not understanding something correctly. But at least I am not worrying anymore. :)
Post Reply

Return to “[3.3.x] Support Forum”