Manual:Wiki in site root directory


It is possible to install MediaWiki in the root directory and have URLs like, but Manual:Short URL does not recommend it.


See Manual:Short URL.


Potential problem Potential solution
Potential need for special rules. You might need special rules for "robots.txt" or "favicon.ico", also for all wiki support files like skin images, extensions that load content from the "/extensions/" folder (such as CSS, JS, or images), and root scripts like api.php, thumb.php, and image_auth.php. You do not need special rules on Apache if you use the following in .htaccess:
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]

This rule allow existing files to be accessed as normal, whether they are in the root directory (e.g. robots.txt) or in sub-directories.

Periodically bugs pop up with various configurations and root URLs because MediaWiki was not designed for them. These are being tracked in task T34620; currently these are the outstanding issues: See below.
  • task T34621: "Root /Foo style article paths and action paths conflict"
It is possible to set up action paths on Apache with the following in LocalSettings.php:
$actions = array( 'view', 'edit', 'watch', 'unwatch', 'delete','revert', 'rollback', 'protect', 'unprotect', 'markpatrolled', 'render', 'submit', 'history', 'purge', 'info' );

foreach ( $actions as $action ) {
    $wgActionPaths[$action] = "/$action/$1";

With the following short URL settings in LocalSettings.php:

$wgScriptPath ="";
$wgArticlePath = "/$1";

and in .htaccess:

RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]

See Manual:$wgActionPaths for details.

  • task T40048: "Root article paths allow creating local-like links to external sites (bypass nofollow, attacks Special:Random)". If a page name begins with a slash (e.g. / it will be rendered as an external link: [[/]] displays as / but links to This also means that Special:Random would redirect straight to the external page.

Similar bugs, not tracked at task T34620, are:

  • task T113160: "Super-short URLs are formed incorrectly for articles with titles starting with a slash".
  • task T141444: "Incorrect treatment of titles starting with a slash when URLs are ultra-short"
You can prevent pages from beginning with a slash by enabling Extension:TitleBlacklist, which comes bundled with MediaWiki, and adding the following line to MediaWiki:Titleblacklist on your site:

This solves the Special:Random and page creation problems, but does not stop someone from adding an internal link to a (non-existent) page like / If you have subpages enabled (as on's manual pages) then it is still not a problem. But if you don't, then the link will be rendered as an external link.

There are a lot of bots scanning random websites searching for known vulnerabilities to exploit, usually performing checks against a list of known URL paths, and they usually request many URLs without delays between them. If your pages start at the root directory, this means each request will hit MediaWiki instead of a plain HTTP 404 error page, which means they will put more strain on your server. It is hard to know the extent of this problem without further details, but many wikis do use the structure, so possibly this problem is more illusory than real.
The structure is not recommended in Manual:Short URL. Use the configuration used by Wikipedia ( if you want to be on the safe side. Apply the solutions above and use if that is your preference.