Manual:Short URL/wiki/Page title -- nginx rewrite--root access

From MediaWiki.org

Jump to: navigation, search

Example configuration:

  • wiki is installed in /w/ directory in http root dir.
  • you want to avoid index.php
  • you want to access articles as /wiki/Article

Then there are two things needed to change in two files:

  • nginx.conf - add below code
location /wiki {
  error_page 404 = @wiki;
  log_not_found of;;
}

location @wiki {
    fastcgi_pass   unix:/path/to/your/socket;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /path/to/site/w/index.php;
    fastcgi_param  QUERY_STRING    title=$fastcgi_script_name;
    include        /usr/local/nginx/conf/fastcgi_params;
}
  • now edit /w/LocalSettings.php
$wgScriptPath	    = "/w";
$wgArticlePath      = "/wiki/$1";
$wgUsePathInfo      = true;

After restarting nginx it should work. The code is not fully rewriting the code cause pages lik Linking to this page or Printable version etc are linked to /w/index.php?... anyway. So this code requires tweaking by more experienced users.