Manual:Short URL/wiki/Page Title -- .htaccess

From mediawiki.org

This modifies the .htaccess file and assumes that your web host does not have "AllowOverride None" specified for the server root (/).

Example URL: http://www.example.com/w/index.php?Title=Main_Page

Short URL: http://www.example.com/wiki/Main_Page

This guide assumes your wiki is installed in a /w directory.

1. Edit or create .htaccess file in public_html (or – in the directory where /w directory is placed) with the following content.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ w/index.php [L,QSA]
RewriteRule ^wiki$ w/index.php [L,QSA]

'RewriteBase' defines where the rewrite will start; the example specifies the root directory.

'RewriteCond' makes sure that links to files (like stylesheets or images) are not rewritten, which can break MediaWiki's formatting in some cases.

'RewriteRule' defines the rewrite; in the example above, '^wiki/(.*)' will invisibly load 'w/index.php?title=$1', where the page name after 'wiki/' will replace '$1'.

2. Add or edit the following setting in LocalSettings.php. This causes the HTML generated by MediaWiki to refer to "/wiki/Articlename" instead of the default.
$wgScriptPath       = "/w";
$wgArticlePath = "/wiki/$1";