Search code examples
mediawiki

MediaWiki custom canonical for a page?


I'm using $wgEnableCanonicalServerLink to generate canonicals.

Plus this solution to serve the main page from the domain root: https://laxstrom.name/blag/2015/08/31/mediawiki-short-urls-with-nginx-and-main-page-without-redirect

My problem is that the main page loaded at http://www.example.com/ domain root still has the long path as the canonical in the source.

Is it possible to set a custom canonical for a page, or solve this issue some other way?


Solution

  • If I set:

    $wgMainPageIsDomainRoot = true;
    $wgEnableCanonicalServerLink = true;
    

    in my LocalSettings.php, the canonical url of my main page is the document root.