Manual:Short URL/wiki/Page title -- nginx rewrite--root access
From MediaWiki.org
Modified from the configuration given on the official Nginx wiki.
Environment scenario:
- MediaWiki has been installed in /var/www/mediawiki directory
- wiki is to be served from wiki.example.com
- you want urls formated as /wiki/Page_Title
There are a few things you need to do:
Add the following text to either nginx.conf or in a new file /etc/nginx/sites-available/mediawiki:
server {
listen 80;
server_name wiki.example.com;
root /var/www/mediawiki;
location / {
index index.php5;
error_page 404 = @mediawiki;
}
location @mediawiki {
rewrite ^/([^?]*)(?:\?(.*))? /index.php5?title=$1&$2 last;
}
location ~ \.php5?$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:8888;
fastcgi_index index.php5;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
If you are using the sites-available approach above, symlink the configuration into sites-enabled
$ sudo ln -s ../sites-available/mediawiki /etc/nginx/sites-enabled/
Add the following lines to the end of your LocalSettings.php file:
$wgScriptPath = ""; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
After reloading the Nginx config, MediaWiki should work with short urls.
$ sudo service nginx reload

