https://bugzilla.wikimedia.org/show_bug.cgi?id=25882
Ilmari Karonen <nos...@vyznev.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nos...@vyznev.net --- Comment #1 from Ilmari Karonen <nos...@vyznev.net> 2010-11-22 20:28:25 UTC --- A wiki I help to run had need for this, so I wrote a quick and dirty hook to add rel=canonical links to all normal page views: $wgHooks['ArticleViewHeader'][] = 'addCanonicalLinks'; function addCanonicalLinks ( &$article ) { global $wgRequest, $wgOut; if ( $article->getOldID() || $wgRequest->getVal( 'redirect' ) == 'no' ) return true; $tags = ( $wgOut->mLinktags ? $wgOut->mLinktags : array() ); foreach ( $tags as $tag ) { if ( $tag['rel'] === 'canonical' ) return true; } $wgOut->addLink( array( 'rel' => 'canonical', 'href' => $article->getTitle()->getFullURL() ) ); return true; } Ideally, of course, we should have some way for extensions and core components to indicate which URL parameters actually affect the content of the page, so that correct canonical links could be automatically constructed for all pages and actions. But this simple workaround should handle 99% of all cases. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l