Basically, you need to add an entry to $wgActionPaths
for each action that you want to use a short URL for.
For example, if you want the normal view URL of the page Foobar
to be /wiki/Foobar
, and the edit and history URLs to be, say, /wiki/edit/Foobar
and /wiki/history/Foobar
, you'd add the following lines to your LocalSettings.php:
$wgArticlePath = '/wiki/$1';
$wgActionPaths['edit'] = '/wiki/edit/$1';
$wgActionPaths['history'] = '/wiki/history/$1';
Of course, you'll also need to configure your web server to rewrite any requests for those short URLs back into something MediaWiki will understand, e.g. using mod_rewrite on Apache. The documentation page I linked to above has some helpful examples.
More generally, you can transform MediaWiki-generated URLs in arbitrary ways using a GetLocalURL or GetLocalURL::Internal hook. (The main difference between the two hooks is that the GetLocalURL hook is also called for interwiki URLs.) These hooks are called from the Title::GetLocalURL(), which you may want to take a look at to see how they work.
For example, here's how you could transform diff URLs into the format /wiki/diff/revA/revB/Page_name
:
function prettyDiffURLs( $title, &$url, $query ) {
if ( preg_match( '/^diff=(\w+)&oldid=(\w+)$/', $query, $matches ) ) {
$dbkey = wfUrlencode( $title->getPrefixedDBkey() );
$url = "/wiki/diff/$matches[1]/$matches[2]/$dbkey";
}
return true;
}
$wgHooks['GetLocalURL::Internal'][] = 'prettyDiffURLs';
(Warning: I believe this code should work, but I have not tested it!)