Short URL for .wiki Domain

From mw.mh370.wiki
Jump to navigation Jump to search


A Guide to Using MediaWiki in a Hosted Environment

An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.


URLs

The default page URL for a MediaWiki-based webpage includes an unwanted path /w/index.php?Title= and the goal is to make that 'pretty' or 'short' by substituting the default path with /wiki.

Two articles explain this in more depth:-

  1. Short URL - covers the common process for rewriting /w/index.php?Title= as /wiki
  2. Short URL for .wiki Domain - covers the special case of a MediaWiki-based website with a top-level domain .wiki, such as this website. To avoid a URL with .wiki/wiki the .htaccess file and configuration in LocalSettings.php must be different from option 1.

See also .htaccess.


Top Level Domain .wiki

The suffix .wiki is a generic Top Level Domain (gTLD) created to identify wikis on the Internet.

Using Google Advanced Search and selecting .wiki for the site or domain (or site:.wiki in a search box) results in a list of wiki websites.

A quick check on a few of these results shows that the URLs do not include /wiki which is the default for MediaWiki short URLs.

MediaWiki-based websites which use other top level domains (.com, .org, .net etc) are not identifiable as wiki sites. When the gTLD .wiki was created it was probably hoped that more wiki-based websites would use or transfer to the new domain.

Removing /wiki from a URL

Page URLs for this website are in the format mw.mh370.wiki/page name.

Page URLs for the mh370wiki.net are in the format mh370wiki.net/page name.

The same technique is used - just remove the /wiki from a typical short URL. This requires a slightly different .htaccess and corresponding configuration in LocalSettings.php.

Two slightly different configurations are presented below:-

  1. Configuration suggested in the Manual:Wiki in site root directory which describes how to have URLs like example.com/pagename.

    .htaccess
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
    RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
    
    LocalSettings.php
    $wgScriptPath = "";
    $wgArticlePath = "/$1";
    
  2. The configuration below works successfully for both this website and mh370wiki.net. Both websites are installed with a directory structure like /public_html/SiteFolder/w because several installations exist in the root directory /public_html.

    .htaccess
    RewriteEngine On
    
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
    RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/w/index.php [L]
    
    RewriteRule ^(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
    
    LocalSettings.php
    ## My Version with no /wiki
    ## Paths work with no-wiki version of htaccess 30 Jan 2025
    $wgScriptPath = "/w";
    $wgArticlePath = "/$1";
    $wgUsePathInfo = false;
    

    The resulting URL is shown here for an article with page name Installation.

The difference between the two versions is subtle. The takeaway is: /wiki can be easily removed from the URL, it just might take a bit patience to get it to work on a specific site.