MediaWiki extensions manual
Release status: unmaintained
Implementation Special page
Description Provides a simple wiki based 404 special page destination
Author(s) Daniel Friesen (Dantmantalk)
MediaWiki 1.25+
PHP 5.3+
Database changes No
License GNU General Public License 2.0 or later
Quarterly downloads 3 (Ranked 135th)
Translate the Special404 extension if it is available at translatewiki.net

The Special404 extension provides a simple wiki based 404 special page destination you can configure for your wiki. The body of the 404 page can also be customized using MediaWiki:Special404-body on your wiki.


  • Download and move the extracted Special404 folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Special404
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Special404' );
  • Add some webserver config to redirect 404s to the special page, usually this is in the form of a .htaccess config, more information in the section below or in the extension's README.
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Web server configuration


Since this is a 404 handler your webserver will need a little configuration to get it working.



Using an ErrorDocument doesn't seem to work in apache, whatever the destination you set, Apache seems to direct to something that MediaWiki interprets normally instead of as a request to display the special page, so we use a rewrite rule instead. You can place the following in your .htaccess file to make the extension work. Be sure to tweak the path to index.php to match the proper path to yours. Also make sure that this is the last rewrite rule, you do not want any rewrite rules after this one they will likely be overridden.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?.*$ /index.php?title=Special:Error404

Keep in mind that it's important that you use /index.php?title=Special:Error404 (with the proper path to index.php of course) and not something like /wiki/Special:Error404 as using the latter causes MediaWiki to treat it normally and direct you to the main page instead of displaying the 404 page.

This rewrite rule is not canonical of cause. For example if you use RewriteBase / rule and your MediaWiki is placed at /w directory (the most usual case) then, the rule will look like this:

RewriteBase /
# ... your other rules ...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?.*$ w/index.php?title=Special:Error404

Use the following web.config in the directory containing /w (do not put it inside /w), and change wiki.example.com to your domain name.

<?xml version="1.0" encoding="UTF-8"?>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^wiki/([^/]+/?[^/]*/?[^/]*)/?$" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <action type="Rewrite" url="w/index.php?title={R:1}" logRewrittenUrl="true" />
				<rule name="RootHitRedirect" stopProcessing="true">
					<match url="^$" />
					<action type="Redirect" url="/w/" />
                <rule name="Fix Old Style URLs">
                    <match url=".*" />
                        <add input="{HTTP_HOST}" pattern="^wiki.example.com$" />
                        <add input="{PATH_INFO}" pattern="^/wiki/" negate="true" />
                        <add input="{PATH_INFO}" pattern="^/w/" negate="true" />
                    <action type="Rewrite" url="\w\index.php?title=Special:Error404" />

The rule in question that makes this extension work for IIS is Fix Old Style URLs. See this page for more details on how these rules were formulated.

Short URLs


If your pages are located at the root directory of your wiki (e.g.: example.com/Page_name), there's no point in installing this extension, because every unknown path of your site will reach MediaWiki, either an existing page, or a non-existing one.

You can edit MediaWiki:noarticletext and MediaWiki:noarticletext-nopermission to customize the text displayed on the non-existing page.