PDA

View Full Version : Change the canonical URLs


vivien.prieur
02-04-2013, 04:26 PM
Hi,

I'd like to know how we can modify the content of the threads' canonical URLs tags in the forum part.

We have a vbulletin integrated within a drupal (news posted on the drupal are duplicated on the vbulletin) and we would need the search engine to reference the portal version of our news and not the forum version.

For that, we need to change the canonical URL generated by the VB Forum into the address of the portal.

For example we want to reference this in google :

http://lol.fureur.org/dossier/lol-guide-carry-ad-item-build-par-chaox

and not this :

http://www.fureur.org/forums/showthread.php?t=44639

And in the forum source code we can see that :

<link rel="canonical" href="showthread.php?t=44639" />

We need that instead :

<link rel="canonical" href="http://lol.fureur.org/dossier/lol-guide-carry-ad-item-build-par-chaox" />

Our URLs are stored in our database and we need to execute a PHP code in order to get them.

It isn't possible for us to do that in a simple .htaccess :/

Is it possible to use a hook (or a hack) in order to choose the way the canonical URL is generated? If yes, how/where would you do that?

Thanks in advance for the answers, please notify me if I'm posting in the wrong part of the forum.

Best regards,

Vivien

Digital Jedi
02-04-2013, 07:59 PM
I might be misinterpreting your questions, but do you not have Friendly URLs enabled in the Admin CP Options?

LifesGreatestGift
02-05-2013, 03:38 AM
one way or another there would need to be a custom field in the vbulletin thread editor to allow you to reference the ID of the post in Drupal. Once you can do that, the rest is just simple database calls and auto-template edits with a FIND-REPLACE for the canonical tag.

--------------- Added 1360039349 at 1360039349 ---------------

That's the somewhat simple method. Another method would be a full blown backend where you would enter forum thread id, drupal post id and do all your php on the backend to prevent users from messing stuff up.

vivien.prieur
02-06-2013, 02:03 PM
I might be misinterpreting your questions, but do you not have Friendly URLs enabled in the Admin CP Options?

Nop since we have to query a DB to find out which URL would be fine for this. And I can't do that with friendly URLs and a simple .htaccess.

one way or another there would need to be a custom field in the vbulletin thread editor to allow you to reference the ID of the post in Drupal. Once you can do that, the rest is just simple database calls and auto-template edits with a FIND-REPLACE for the canonical tag.

--------------- Added 05 Feb 2013 at 05:42 ---------------

That's the somewhat simple method. Another method would be a full blown backend where you would enter forum thread id, drupal post id and do all your php on the backend to prevent users from messing stuff up.

That would be more what i'd like to have. Any idea of where exactly I could add this custom field?