Serving Mediawiki from a Subdirectory with Nginx Revision as of Friday, 4 June 2021 at 03:52 UTC

/etc/nginx/conf.d/wiki.conf

server {
    listen 80;
    server_name example.com;

    root   /alternate/var/www/html;
    index  index.html index.htm index.php;

    # Redirect to Mediawiki install path
    location /wiki {
        try_files $uri $uri/ @wiki_rewrite;
    }
    location @wiki_rewrite {
        rewrite ^/wiki/(.*)$ /mediawiki/index.php?title=$1&$args;
    }
}

LocalSettings.php

    $wgServer      = "http://example.com";
    $wgScriptPath  = "/mediawiki";
    $wgArticlePath = "/wiki/$1";
    $wgUsePathInfo = true;